07-26-2011
I dont know, whether u red the full page or not.
In the end of the page, you can see the below lines.
Note: In the C shell, use the following command to run the getopt command:
set argv=`getopt OptionString $*`
10 More Discussions You Might Find Interesting
1. Programming
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)
Discussion started by: angelfly
1 Replies
2. Shell Programming and Scripting
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)
Discussion started by: problems
1 Replies
3. Shell Programming and Scripting
#!/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)
Discussion started by: Hitori
6 Replies
4. UNIX for Dummies Questions & Answers
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)
Discussion started by: Guillermo Lopez
2 Replies
5. Shell Programming and Scripting
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)
Discussion started by: pollsizer
1 Replies
6. Shell Programming and Scripting
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)
Discussion started by: darshakraut
2 Replies
7. Shell Programming and Scripting
:)
Can anybody help me about how to use getopt in shell scripting. (3 Replies)
Discussion started by: darshakraut
3 Replies
8. Shell Programming and Scripting
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)
Discussion started by: giorgos193
5 Replies
9. Shell Programming and Scripting
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)
Discussion started by: Breakology
3 Replies
10. Shell Programming and Scripting
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)
Discussion started by: mutley2202
1 Replies
getopt(1) General Commands Manual getopt(1)
NAME
getopt - Parses command line flags and arguments
SYNOPSIS
getopt format tokens
DESCRIPTION
The getopt command is used to parse a list of tokens using a format that specifies expected flags and arguments. A flag is a single ASCII
letter and, when followed by a : (colon), is expected to take a modifying argument that may or may not be separated from it by one or more
tabs or spaces. (You can include multi-byte characters in arguments, but not as flag letters.)
The getopt command completes processing when it has read all tokens or when it encounters the special token -- (double dash). It then out-
puts the processed flags, a --, and any remaining tokens.
If a token fails to match a flag, getopt writes a message to standard error.
NOTES
In the csh, use the following command to run getopt:
set argv=`getopt flag_string $*`
EXAMPLES
The following is an example of the use of getopt in a skeleton shell script to parse options:
#!/bin/sh # parse command line into arguments set -- `getopt a:bc $*` # check result of parsing if [ $? != 0 ] then
exit 1 fi while [ $1 != -- ] do
case $1 in
-a) # set up the -a flag
AFLG=1
AARG=$2
shift;;
-b) # set up the -b flag
BFLG=1;;
-c) # set up the -c flag
CFLG=1;;
esac
shift # next flag done shift # skip double dash # now do the work . . .
The following are all equivalent arguments to the script:
-a ARG -b -c -- A B C -a ARG -bc -- A B C -aARG -b -c -- A B C -b -c -a ARG -- A B C
SEE ALSO
Commands: sh(1)
Functions: getopt(3)
getopt(1)