Intersperse arguments and options w/ getopts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Intersperse arguments and options w/ getopts
# 1  
Old 12-09-2010
Question

Is it possible to get a script that uses getopts to accept options and arguments in any order?

eg. -g -h 2 4 works like -g 2 -h 4.

Last edited by lee.n.doan; 12-09-2010 at 10:35 AM..
# 2  
Old 12-09-2010
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using getopts for handling multiple options

Hi Guys, I have created a script for our automated DB creation, it works fine with default option(-d). $ ./test_db.ksh -d abc 11 dev -d is Default option ORACLE_SID=abc ORACLE_VERSION=11 ENV_TYPE=dev For creating a customized DB, i thought of giving the user different options.... (8 Replies)
Discussion started by: veeresh_15
8 Replies

2. Shell Programming and Scripting

Processing Multiple Arguments in Command Line Options

Hi All, I am new to scripting. Could you please assist me . Here is my requirement. I have written a script that has 2 option flags defined. -l) calls some function with the arguments passed in front of -l -r) calls second function with the arguments passed in front of -r *) calls the... (7 Replies)
Discussion started by: Jay Deshpande
7 Replies

3. Shell Programming and Scripting

grep with two arguments to arguments to surch for

Hello, is it possible to give grep two documents to surche for? like grep "test" /home/one.txt AND /home/two.txt ? thanks (1 Reply)
Discussion started by: Cybertron
1 Replies

4. Shell Programming and Scripting

Need help with parsing the arguments using getopts !!

Hi all, I am trying to use long arguments for my existing script. right now my script would work if given <script_name> -t <arg1> -b <arg2> -v <arg3>. The script code is shown below. while getopts t:v:b: OPT;do case "$OPT" in t) Todo=$OPTARG;; b) Batch=$OPTARG;; ... (3 Replies)
Discussion started by: SSSB
3 Replies

5. UNIX for Dummies Questions & Answers

getopts - command line arguments

Hi, I'm having problems with a script where I wanted every single option specified in the command line to have an argument taken with it, but for some reason only d works in the code I will be showing below. For example if I did ./thisfile -a something it would come up with "a chosen with " as... (2 Replies)
Discussion started by: IceX
2 Replies

6. Shell Programming and Scripting

Help with options and arguments to a script

I'm trying to write a script that accepts both arguments and options, e.g. ./script -h 1 -m 15 -s 30 or ./script -h 1 -m 15 -s 30 I'd like for any of the arguments and options to be optional, and the option values should be numerals only. I've tried both getopt and getopts but I... (1 Reply)
Discussion started by: Ilja
1 Replies

7. Shell Programming and Scripting

getopts with non-option arguments?

Hello everyone, Is it possible to use getopts and also receive arguments without option flags? e.g. myscript arg1 arg2 -a arg3 -b arg4 If so, how do you stop getopts from exiting as soon as it detects the non-option arguments? (2 Replies)
Discussion started by: kdelok
2 Replies

8. Shell Programming and Scripting

getopts takes options for parameters

Here is my post with a question about getopts. I am running korn shell on Solaris 5.8. I am trying to ensure that certain options require a parameter, which is easy enough. I have found that if multiple options are entered on the command line together, but the parameter for one of the options is... (1 Reply)
Discussion started by: UCD-Randy
1 Replies
Login or Register to Ask a Question