We help IT Professionals succeed at work.

parameters in the shell? order

enrique_aeo
enrique_aeo asked
on
i have this store procedure
PROCEDURE SP_EXTRAE_DEV(  
          PI_USUARIO IN VARCHAR2,
          PI_FECHA_DEVOLUCION_INI IN VARCHAR2,
          PI_FECHA_DEVOLUCION_FIN IN VARCHAR2,
          PI_MSISDN IN VARCHAR2,          
         codError OUT NUMBER,
          desError OUT VARCHAR2 ) IS

There are several scenarios when called from the Shell
 1. If I send a parameter from Shell brings information from the previous day, this is controlled by the sp and works well
2. If you want to send a date range I run this way and works well
sh nameSHELL 20111011 20111011
3.
My question is how do I make the call to Shell if I just want to send the pi_msisdn, try to do so:
sh nameshell null null 511997274580 but it is not work

this is the code in the shell
if [[ -z $1 ]]
then
           #do something
           USER_SERV=`whoami`
else
            PI_FECHA_DEVOLUCION_INI=$1
            PI_FECHA_DEVOLUCION_FIN=$2
fi
#MSISDN
if [[ -z $3 ]]
then
           #do something
            USER_SERV=`whoami`
else
            PI_MSISDN=$3
fi

Comment
Watch Question

SILVER EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019

Commented:
try:
sh nameshell "" "" 511997274580


From your previous question this is why I kept asking about the number and position of the parameters and you never answered.

In that question getopts was mentioned.

I would use it, then the order and number doesn't matter.

for example:
sh nameshell -s 20111011 -e 20111011 -p 511997274580
sh nameshell -p 511997274580
etc...


There are many examples out there on getopts and shell scripts

Here is the first one I cam across:
http://www.mkssoftware.com/docs/man1/getopts.1.asp
Hi

You should run the procedure as following:


PROCEDURE SP_EXTRAE_DEV( PI_USUARIO=>null,PI_FECHA_DEVOLUCION_INI=>null, PI_FECHA_DEVOLUCION_FIN =>null, PI_MSISDN=>511997274580,ou1,ou2);

Regards,
Jarek

Author

Commented:
the page
http://www.mkssoftware.com/docs/man1/getopts.1.asp 
it is not working, another please?
SILVER EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019

Commented:
>>it is not working, another please?

Define not working.

If you are trying to implement getopts, please provide a simple sample, not your complete code, shell script that shows the errors you are receiving.

Author

Commented:
the message is
Internet Explorer cannot display the webpage
SILVER EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019
Commented:
OH, the URL itself won't load.

There are a TON of examples out there:
http://www.google.com/#hl=en&q=shell+script+getopts

Explore More ContentExplore courses, solutions, and other research materials related to this topic.