On my Java webpage which invokes the shell script has two checkboxes viz ...
apache
and
weblogic
apache require one parameter i.e apache home from the user while Weblogic requires three or five params from the user vi.z weblogic_home or <jdk_home, config_home & pid>, username and password.
The use may choose to select any one product or both(apache and weblogic)
Thus the possible user inputs can be
selecting either apache or weblogic or both.
if apache is selected then one paramter must be passed
if weblogic is selected either 3 or 5 paramters should be passed to the script
Anything more or less that the user inputs should terminate the script with exception message.
Based on the situation mentioned in the OP the user input is variant, how will we come to know if the user selected which product [apache or weblogic or both?] and how many parameters has he passed ? I don't think it is as easy as simply knowing the case statement.
Situation 1: The user only inputs "Weblogic" Then the $2, $3 $4 are the pid, username and password for weblogic [./script.sh weblogic 34522 user1 pswd]
Situation 2: If the user Enters both Apache and Weblogic then $4, $5, $6 are the pid username and password [./script.sh apache /opt/apache22 weblogic 34522 user1 pswd].
Also, I mentioned that weblogic input can be 3 or 5 params long.