How-To Check & Filter user input

Hi,

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

  1. selecting either apache or weblogic or both.
  2. if apache is selected then one paramter must be passed
  3. 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.

Please let me know how could it be implemented ?

check

case

statement.

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.

I guess you want that if user select

apache

it must do some specific task and if it select

weblogic

it must do some other task.

So you can specify this in

case

statement. Have a look at some examples.

let me try to make you understand.

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.

How will this be achieved ?