How-To Check & Filter user input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How-To Check & Filter user input
# 1  
Old 02-25-2013
Hammer & Screwdriver 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 ?

Last edited by mohtashims; 02-25-2013 at 08:47 AM..
# 2  
Old 02-25-2013
check
Code:
case

statement.
# 3  
Old 02-25-2013
Quote:
Originally Posted by Vikram_Tanwar12
check
Code:
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.
# 4  
Old 02-25-2013
I guess you want that if user select
Code:
apache

it must do some specific task and if it select
Code:
weblogic

it must do some other task.

So you can specify this in
Code:
case

statement. Have a look at some examples.
# 5  
Old 02-25-2013
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 ?

Last edited by mohtashims; 02-25-2013 at 09:36 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Would like to check user input for letters within a loop

Hi All, #!/bin/bash #Just trying to check if letters are in the user input. Any tips? # I have tried regexp and using 0-9 etc, i cannot get this to work either in just an if statement or while in a loop. echo "Please pick a number" read num if ; then echo "Please enter a number"... (7 Replies)
Discussion started by: jvezinat
7 Replies

2. Shell Programming and Scripting

How to check the user input to be valid using shell script?

How to check the user input to be valid using shell script? The valid input is in the format like as follows. 1. It can only have r,w,x or a hyphen and nothing else. 2. ensure the r, w, x are in the correct order. for example: rwxr-xr-x is a valid format. Thanks (5 Replies)
Discussion started by: hyeewang
5 Replies

3. Shell Programming and Scripting

Check user input

Hi, I need my script to check if the user enters 3 values if not 5 values to my script and alert if the input has any other number of values. for example: ./myscript.sh 22 56 3221 - > correct ./myscript.sh 22 56 3221 45 777 -> correct ./myscript.sh 22 56 3221 45 -> incorrect Please... (6 Replies)
Discussion started by: mohtashims
6 Replies

4. Homework & Coursework Questions

Function to Check if string input from user is alphabetic only

Good Evening. I'm new to C. Can you please help me. I'm creating an error checking function, user will input a string, this will check if the input is all alphabet or all letters only. If there is a digit or other special char, it will print Error then ask input from user again. Here's my... (1 Reply)
Discussion started by: eracav
1 Replies

5. Homework & Coursework Questions

[Scripting]Find & replace using user input then replacing text after

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: (o) Checkout an auto part: should prompt the user for the name of the auto part and borrower's name: Name:... (2 Replies)
Discussion started by: SlapnutsGT
2 Replies

6. Shell Programming and Scripting

find & replace with user input

Trying to create a script/executable to replace "abc" text string in "myfile.htm" with input from a pop-up field. For example, launch this thing and a prompt is popped up asking the user to input what "abc" should be replaced with, then it inserts what the user inputs in place of abc in the... (3 Replies)
Discussion started by: mike909
3 Replies

7. UNIX for Dummies Questions & Answers

how to check the user input from terminal

Hello everybody!!! I am writing my own rm command in unix. I prompt the user to type if he wants to delete a file and then read what he typed. But how do i check what he typed? This is my program so far: echo 'Delete prog1.c (y/n)?' read yesOrNo if yesOrNo == 'y' then rm prog1.c... (6 Replies)
Discussion started by: mskart
6 Replies

8. Shell Programming and Scripting

filter input & outputs to another file

Hello All, I am stuck with the follwing problem , pls give me some advice.. Input file: input clock; input reset; \\reset all input yuv; //input comment output sur; output sud; output vtua; output tur; input ebi; //output comment The input file... (1 Reply)
Discussion started by: user_prady
1 Replies

9. Shell Programming and Scripting

Bash : how do i check the user input and make sure is only chracter or only number ?

Bash : how do i check the user input and make sure is only character or only number ? (7 Replies)
Discussion started by: CheeSen
7 Replies

10. Shell Programming and Scripting

How to prompt for input & accept input in ONE line

hi, am a new learner to shell programming. i have a script which will prompt for user to key in their name & display their name afterwards. script ===== echo "Pls enter your name:" read name echo "Your name is $name." output ===== Pls enter your name: Bob Your name is Bob. what... (2 Replies)
Discussion started by: newbie168
2 Replies
Login or Register to Ask a Question