The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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 google Shell Programming and Scripting 3 12-05-2002 04:42 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-08-2005
stefan_hery's Avatar
Registered User
 

Join Date: May 2005
Location: Melbourne
Posts: 2
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..
Reply With Quote
Forum Sponsor
  #2  
Old 05-08-2005
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
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.
Reply With Quote
  #3  
Old 05-08-2005
stefan_hery's Avatar
Registered User
 

Join Date: May 2005
Location: Melbourne
Posts: 2
Thumbs up

Thanks for the idea..
It really work..

Cheers,
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0