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..

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.

Thanks for the idea..
It really work..

Cheers,