you could ditch the -r requirement and have it's options as the last parameters on the command line.
the roi variable will now have the rest of the command line, so if it was called thus:
then the output would be:
and if you didn't want the roi variable to be quoted, as I have it here, then remove the single quotes around '$*' on the line in red above.
Hope this helps, and never give up, it is never tooooo difficult.
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)
#!/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)
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)
Hi,
I have a perl script with two functions say func a and func b.
sub a {
-----------
---------
}
sub b {
---------
---------
}
I want to use this function on command line as we can do in shell script using getopt.
My motto here is to run the script like this
... (7 Replies)
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 am in middle of using some getopt command and am finding some issue. The usage of my script can be like this:
abc.sh <-d | -p |-r> -online < 0 | 1>
The first argument can be either -d or -p or -r. The second argument can be either -s and a id or a file name. So I am stuck up in writing... (2 Replies)
Hi
I need to use getopt option and I have no idea what it is or how to use it.
I need to use it on this awk script:
awk -F, -v cellid="$1" -v paramval="$2" -v oldfile="$3" -v newfile="$4" '$2==cellid{$3=newvalue}1' OFS="," $3 > $4
I tried reading up on it but I just confuse... (2 Replies)
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
LEARN ABOUT HPUX
getopt
getopt(1) General Commands Manual getopt(1)NAME
getopt - parse command options
SYNOPSIS
optstring args
DESCRIPTION
is used to break up options in command lines for easy parsing by shell procedures and to check for legal options. optstring is a string of
recognized option letters (see getopt(3C)). If a letter is followed by a colon, the option is expected to have an argument, which may or
may not be separated from it by whitespace.
The positional parameters ...) of the shell are reset so that each option is preceded by a and is in its own positional parameter; each
option argument is also parsed into its own positional parameter.
recognizes two hyphens to delimit the end of the options. If absent, places at the end of the options.
The most common use of is in the shell's command (see the example below) where converts the command line to a more easily parsed form.
writes the modified command line to the standard output.
EXTERNAL INFLUENCES
Environment Variables
determines the language in which messages are displayed.
If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari-
able.
If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable
contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5).
International Code Set Support
Single-byte and multibyte character code sets are supported.
DIAGNOSTICS
prints an error message on the standard error when it encounters an option letter that is not included in optstring.
EXAMPLES
The following code fragment processes the arguments for a command that can take the options or and the option which requires an argument:
This code accepts any of the following as equivalent:
WARNINGS
option arguments must not be null strings nor contain embedded blanks.
SEE ALSO getopts(1), sh(1), getopt(3C).
getopt(1)