Home » Infrastructure » Unix » How can I add the 10 th parameter to the shell script
How can I add the 10 th parameter to the shell script [message #171155] Mon, 08 May 2006 13:57 Go to next message
a04417
Messages: 3
Registered: May 2006
Location: King of Prussia, PA
Junior Member
What if the shell script takes more than 9 parameters?? How do I access the 10th parameters thru shell script???
I need to call a PL/SQL procedure
PFPC_INVOICES_PROC (v_check_date in VARCHAR2, v_set_of_books_id in NUMBER)
that has two IN parameters from the shell script?
example of my code using one parameter:
>
> v_date="" # Input Parameter
>
> ##echo "Show" $#
> v_param_cnt=0
> v_date='2001-01-01'
> for var in $*
> do
> v_param_cnt=$v_param_cnt+1
> ## echo "$v_param_cnt Input Parameter= $var"
> if ((v_param_cnt=9))
> then
> v_date=$var
> else
> echo "Some Other Parameter= $var"
> fi
> done
> ###########################
> # Display Current Status #
> ###########################
> v_date="'$v_date'"
> ##echo "Converted Date= $v_date"
> #################################
> # start main package procedure: #
> #################################
> LOGIN=`cat /u01/ora11/.apps_login`
> sqlplus
$LOGIN
set serveroutput on size 1000000;
set feedback off;
exec DBMS_OUTPUT.put_line('Procedure PFPC_INVOICES_PROC In Execution Mode...');
BEGIN
PFPC_INVOICES_PROC($v_date);
DBMS_OUTPUT.put_line('Procedure PFPC_INVOICES_PROC is done...');
EXCEPTION
Re: How can I add the 10 th parameter to the shell script [message #171157 is a reply to message #171155] Mon, 08 May 2006 14:45 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Use shift?
http://learnlinux.tsf.org.za/courses/build/shell-scripting/ch06s03.html

[Updated on: Mon, 08 May 2006 14:46]

Report message to a moderator

Re: How can I add the 10 th parameter to the shell script [message #171417 is a reply to message #171157] Tue, 09 May 2006 19:53 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
you should be able to make it look like fewer parameters by bundling some together with quotes. This isn't working code, but you'll get the idea...

t.ksh 123 abc def ghij 777
----- --- --- --- ---- ---
 $0    $1  $2  $3   $4  $5

t.ksh 123 "abc def ghij" 777
----- ---  ------------  ---
 $0    $1      $2        $3

echo $2 | read X Y Z
then $X contains abc

So $2 becomes "abc def ghij" and then you can split it up further inside your script.
Re: How can I add the 10 th parameter to the shell script [message #171482 is a reply to message #171417] Wed, 10 May 2006 03:46 Go to previous messageGo to next message
tarundua
Messages: 1080
Registered: June 2005
Location: India
Senior Member

As mahesh suggested use "Shift".
"Shift" is the better option when you have more command line parameters.
Re: How can I add the 10 th parameter to the shell script [message #171608 is a reply to message #171417] Wed, 10 May 2006 09:37 Go to previous messageGo to next message
a04417
Messages: 3
Registered: May 2006
Location: King of Prussia, PA
Junior Member
Thank you for you reply, but I sent the wrong shell script.
The problem is: I have PL/SQL procedure with IN parameters date and number. Users will enter first date and then number. Date is parameter 9, number is parameter 10
CREATE OR REPLACE PROCEDURE PFPC_INACTIVE_SUPPLIERS_TEST (v_check_date in VARCHAR2, v_set_of_books_id in NUMBER)
IS
Then, in the shell script I need to call procedure with parameters.
#!/bin/ksh
# This script is to run a data extract
# from oracle and to push the data to the
# mainframe.
##. /u01/ora11/appdappl/APPSORA.env
## v_temp_ret_code=0 # SHELL Temporary Return Status code
##echo $v_temp_ret_code
## v_ret_code=0 # SHELL Return Status code
##echo $v_ret_code
v_check_date="" # Input Parameter
v_set_of_books_id=0

##`v_check_date '+%d%b%Y'`
echo "Show" $#
v_param_cnt=0
for var in $*
do
v_param_cnt=$v_param_cnt+1
echo "$v_param_cnt Input Parameter= $var"
if ((v_param_cnt=9))
then
v_check_date=$var
else
echo "Some Other Parameter= $var"
fi
done

for num in $*
do
v_param_cnt=$v_param_cnt+1
if
((v_param_cnt=10))
then
v_set_of_books_id=$num
else
echo "Some Other Parameter= $num"
fi
done

# Display Current Status #
###########################
v_check_date="'$v_check_date'"
echo "Converted Date= $v_check_date"
v_set_of_books_id=$v_set_of_books_id
echo "Set Of Books ID = $v_set_of_books_id"

#################################
# start main package procedure: #
#################################
LOGIN=`cat /u01/ora11/.apps_login`
sqlplus << EOJ
$LOGIN
set serveroutput on size 1000000;
set feedback off;
exec DBMS_OUTPUT.put_line('Procedure PFPC_INACTIVE_SUPPLIERS_TEST In Execution Mode...');
BEGIN
PFPC_INACTIVE_SUPPLIERS_TEST($v_check_date, $v_set_of_books_id);
DBMS_OUTPUT.put_line('Procedure PFPC_INACTIVE_SUPPLIERS_TEST is done...');
EXCEPTION
Re: How can I add the 10 th parameter to the shell script [message #171610 is a reply to message #171157] Wed, 10 May 2006 09:45 Go to previous message
a04417
Messages: 3
Registered: May 2006
Location: King of Prussia, PA
Junior Member
Thank you for you reply, but I sent the wrong shell script.
The problem is: I have PL/SQL procedure with IN parameters date and number. Users will enter first date and then number. Date is parameter 9, number is parameter 10
CREATE OR REPLACE PROCEDURE PFPC_INACTIVE_SUPPLIERS_TEST (v_check_date in VARCHAR2, v_set_of_books_id in NUMBER)
IS
Then, in the shell script I need to call procedure with parameters.
#!/bin/ksh
# This script is to run a data extract
# from oracle and to push the data to the
# mainframe.
##. /u01/ora11/appdappl/APPSORA.env
## v_temp_ret_code=0 # SHELL Temporary Return Status code
##echo $v_temp_ret_code
## v_ret_code=0 # SHELL Return Status code
##echo $v_ret_code
v_check_date="" # Input Parameter
v_set_of_books_id=0

##`v_check_date '+%d%b%Y'`
echo "Show" $#
v_param_cnt=0
for var in $*
do
v_param_cnt=$v_param_cnt+1
echo "$v_param_cnt Input Parameter= $var"
if ((v_param_cnt=9))
then
v_check_date=$var
else
echo "Some Other Parameter= $var"
fi
done

for num in $*
do
v_param_cnt=$v_param_cnt+1
if
((v_param_cnt=10))
then
v_set_of_books_id=$num
else
echo "Some Other Parameter= $num"
fi
done

# Display Current Status #
###########################
v_check_date="'$v_check_date'"
echo "Converted Date= $v_check_date"
v_set_of_books_id=$v_set_of_books_id
echo "Set Of Books ID = $v_set_of_books_id"

#################################
# start main package procedure: #
#################################
LOGIN=`cat /u01/ora11/.apps_login`
sqlplus << EOJ
$LOGIN
set serveroutput on size 1000000;
set feedback off;
exec DBMS_OUTPUT.put_line('Procedure PFPC_INACTIVE_SUPPLIERS_TEST In Execution Mode...');
BEGIN
PFPC_INACTIVE_SUPPLIERS_TEST($v_check_date, $v_set_of_books_id);
DBMS_OUTPUT.put_line('Procedure PFPC_INACTIVE_SUPPLIERS_TEST is done...');
EXCEPTION
Previous Topic: shell script
Next Topic: Read contents of text file using unix shell scripts
Goto Forum:
  


Current Time: Mon Nov 25 17:58:47 CST 2024