passing options to a shell script - bsd.freebsd.misc
This is a discussion on passing options to a shell script - bsd.freebsd.misc ; Hi, im trying to write a script that will accept two options out of a list of 5 options. The first set of options comprise --test, --real and -- verbose, the second set of options comprises --months and --year and ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| im trying to write a script that will accept two options out of a list of 5 options. The first set of options comprise --test, --real and -- verbose, the second set of options comprises --months and --year and it takes variables for each. What i am trying to accomplish is, when any one of the first set of variables is passed, a second from that set cannot be passed, and when an attempt to pass more than one option from the first set an error is given. the same applies to the second set of options. I am using getopts to get the options, but failed to find a way to restrict usage of only one option from the two sets of options. any guidance appreciated. Regards, Mike |
|
#2
| |||
| |||
| barnard wrote: > Hi, > > im trying to write a script that will accept two options out of a list > of 5 options. The first set of options comprise --test, --real and -- > verbose, the second set of options comprises --months and --year and > it takes variables for each. > > What i am trying to accomplish is, when any one of the first set of > variables is passed, a second from that set cannot be passed, and when > an attempt to pass more than one option from the first set an error is > given. the same applies to the second set of options. > > I am using getopts to get the options, but failed to find a way to > restrict usage of only one option from the two sets of options. After parsing the options, just check wether you have seen options from both mutually exclusive sets. Like if test -n "$DATE" && test -n "$MODE"; then .... > any guidance appreciated. My pleasure. Regards - M |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 12:38 PM.




Linear Mode