![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using getopts | TurboArkhan | Shell Programming and Scripting | 2 | 03-05-2008 04:01 PM |
| Help in getopts | chella | Shell Programming and Scripting | 4 | 11-01-2007 10:09 PM |
| getopts help | GrepMe | Shell Programming and Scripting | 3 | 06-20-2007 08:47 AM |
| help in getopts | problems | Shell Programming and Scripting | 1 | 05-04-2006 08:07 PM |
| getopts | Shell Programming and Scripting | 3 | 12-05-2002 04:42 PM | |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Advanced Getopts
Hi all,
I am using getops to get the arguments passed by the command line. However, I need to specify some rules regarding the parameter sent. For eg: I have script called MyScript which accept parameter d, I, E, r, u so the usage should be like this: MyScript [-d N] [-I] [-E] [-r] [-u string] So far, I finished that part. But, what I want to do now is: Suppose if user specify parameter d, it should not accept parameter I and E If user want to use parameter r and u, it should be accompanied by parameter d , I, or E So, MyScript -d5 -I -> InCorrect (should return error) MyScript -d5 -> Correct MyScript -r -> InCorrect MyScript -r -I -> Correct Could anyone help me.. Thx in advance.. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
You could do this by specifying a check sum in your getopts statement. At the end of the getsopts statement and before any other code is executed, check to see if the checksum value is what is expected. Here is a thread that you could use to show you how to go about it.
|
|
#3
|
||||
|
||||
|
Thanks for the idea..
It really work.. Cheers, |
||||
| Google The UNIX and Linux Forums |