Thanks, I regret I did miss it.
I am facing trouble in writing the <optionstring $*> part for getopt. Can you please help me out.
I will write in brief what i have understood,I need you to correct me if i am wrong anywhere.
AS is given in code
where we are trying to list flags and arguments.
hence a is a flag with arguments and b,c are just flags.
Q) What is the significance of $* after optionstring? is it just syntax? (I know what is $*=list all args)
end of getopt processing: When it has read all tokens or it has encountered a specialtoken --.
The getopt command then outputs the processed flags, a — (double hyphen), and any remaining tokens.
can you explain the bold lines above?
also, we have saved the getopt's output in a argv, so am i correct to say that argv is an array , which stores all output from a. using shift we can pop a recently used value and get ready to access next value.
---------- Post updated at 12:50 PM ---------- Previous update was at 12:15 PM ----------
Hi All,
An old work friend wrote a script which I've been trying to understand how a section of it currently works and work out how i can add some command line switches which i can use later in the script to append the output depending on the command line arguements.
Currently it works by... (1 Reply)
I am working on a script that lists files in a directory with a few file attributes depending on what option the user specifies at the command prompt. The script uses Getopt::Std and takes two switches.
The first switch allows the user to specify a directory, the second switch gives a long... (3 Replies)
Hi,
I want to use the getopt function to parse some arguments for a script.
while getopts "i:f:r:" OPTION
do
case $OPTION in
i) iter=$OPTARG;;
f) frame=$OPTARG;;
r) roi=$OPTARG;;
?) echo Usage: ......
exit 2;;
esac
done
However, I... (5 Replies)
I m trying to use getopt
This is my script, but it doesn't take argument in variable,
Please help.
set - - `getopt mscl: $*`
if
then
echo "Exiting...."
exit 2
fi
for i in $*
do
case $i in
-m) MAIL="$i"; shift;;
-s) SCRIPT=$OPTARG; shift;;
-c) COB=$OPTARG; shift;;... (2 Replies)
I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them)
Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Is there a way to get getopt/getopts to work in csh?
I know... csh is not a good shell. Nobody should be using it but I have to deal with old scripts already coded using this shell and therefore I have to do some maintenance to them...
Any ideas about how to get it to work? I did recode some sh... (2 Replies)
#!/bin/sh
set -- `getopt "abco:" "$@"`
a= b= c= o=
while :
do
case "$1" in
-a) a=1;;
-b) b=1;;
-c) c=1;;
-o) shift; o="$1";;
--) break;;
esac
shift
done
shift # get rid of --
# rest of script...
# e.g.
ls -l $@ (6 Replies)
scriptname
i have made a script to perform so tasks and i managed to complete the tasks for all the options
the problem i am facing is that i can run the scripts individually but i would like to make it such that it can accept multiple options and give me the appropriate output
e.g.... (1 Reply)
I'm using getopt() to get command line options.One the optons accepts and argument.The argument is and offset.I was wondering how can I scecify that it's argument is of the type off_t.I've something like this "offset=(off_t)optarg" and it don't work. (1 Reply)