command line options

command line options

Post by EXCHANGE:CAR:9L » Thu, 04 Feb 1999 04:00:00



I have a program that excepts a -q# option
I am able to check for the -q option using:

            if ($argv[2] =~ -q*) then
                echo "got a -q"

but now i want to store everything after the -q in a variable.
ex. mycommand -q91 (i want the 91 in a variable)

Neil

 
 
 

command line options

Post by J. S. Jense » Thu, 04 Feb 1999 04:00:00



> I have a program that excepts a -q# option

Use `getopts'

--
J. S. Jensen

http://www.Paramin.COM

 
 
 

command line options

Post by Ken Pizzi » Thu, 04 Feb 1999 04:00:00


On Wed, 03 Feb 1999 13:18:40 -0500,

Quote:>I have a program that excepts a -q# option
>I am able to check for the -q option using:

>            if ($argv[2] =~ -q*) then
>                echo "got a -q"

>but now i want to store everything after the -q in a variable.
>ex. mycommand -q91 (i want the 91 in a variable)

var=`expr $argv[2] : '-q\(.*\)'`

                --Ken Pizzini

 
 
 

command line options

Post by Carlos J. G. Duar » Mon, 08 Feb 1999 04:00:00



Quote:> I have a program that excepts a -q# option
> I am able to check for the -q option using:
>             if ($argv[2] =~ -q*) then
>                 echo "got a -q"
> but now i want to store everything after the -q in a variable.
> ex. mycommand -q91 (i want the 91 in a variable)

for example: (seems you are using csh scripting)

        set opt = `echo $argv[2] | cut -c3-`

--
carlos