Taking one input at a time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Taking one input at a time
# 1  
Old 06-23-2011
Taking one input at a time

Legends,

Please help me to come out of the below Bermuda triangle.

I have four inputs in a shell script: A B C D
Now, If A is passed by user then, B C D will be ignored.
If C is passed by user, then A B D will be ignored.

Regards,
Sandy
# 2  
Old 06-23-2011
case statement in shell will help you.
# 3  
Old 06-23-2011
What A, B, C and D are: positional parameters or literal values?
# 4  
Old 06-23-2011
I am using the below case statement, but it is not working


Code:
case $SYSTEM_NAME in
        A) echo "The script will not run on B C D

        C) echo "The script will not run on B A D

        *) echo "\nInvalid Input..."
esac


Last edited by radoulov; 06-23-2011 at 06:12 AM.. Reason: Code tags.
# 5  
Old 06-23-2011
Code:
case $SYSTEM_NAME in         
  A ) echo "The script will not run on B C D ;;          
  C ) echo "The script will not run on B A D ;;          
  * ) echo "\nInvalid Input..." ;; 
esac

VBut you should decide the precedence, with the above script A takes precedence over C.
# 6  
Old 06-23-2011
yes true, there were multiple lines so ( ;; ) were inserted in end, and were removed while pasting here to shorten the code
# 7  
Old 06-23-2011
What this statement means:

Quote:
If C is passed by user, then A B D will be ignored.
If both A and C are passed, the script will use only A.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in taking input Shell script

I was writing a shell script, where i need to run a command through script and then take input from user and later terminate it. i am not sure how to take input in a proper format immediately after a command. example: below command line is used to import some data in to database (LDAP)... (3 Replies)
Discussion started by: Mridul17
3 Replies

2. Shell Programming and Scripting

Process running time by taking user input

Need help in scripting . Below is the situation and need your inputs Checking all the processes, scripts running time based on user input time . Below Example ps -aef -o user,pid,etime,stime,args| grep sleep <user> 28995 01:24 14:14:39 sleep 120 <user> 29385 00:52 14:15:10... (8 Replies)
Discussion started by: ajayram_arya
8 Replies

3. UNIX for Dummies Questions & Answers

ls is taking long time to list

Hi, All the data are kept on Netapp using NFS. some directories are so fast when doing ls but few of them are slow. After doing few times, it becomes fast. Then again after few minutes, it becomes slow again. Can you advise what's going on? This one directory I am very interested is giving... (3 Replies)
Discussion started by: samnyc
3 Replies

4. UNIX for Dummies Questions & Answers

SED taking too much time

Hi I am trying to remove some characters from my data file. The data file has huge number of records say 90000 records. I am using sed for this purpose. eg : cat FILENAME|sed 's/;//g' (to remove semi colon ';') However as the data file is too huge , it is taking too much time to give... (3 Replies)
Discussion started by: dashing201
3 Replies

5. UNIX for Dummies Questions & Answers

Job is taking long time

Hi , We have 20 jobs are scheduled. In that one of our job is taking long time ,it's not completing. If we are not terminating it's running infinity time actually the job completion time is 5 minutes. The job is deleting some records from the table and two insert statements and one select... (7 Replies)
Discussion started by: ajaykumarkona
7 Replies

6. Shell Programming and Scripting

Problem while taking input from User

Hi All, I am facing a problem while taking input from user in Shell Script. Basically , I want to read a file line by line. And I want to remove certain lines of that file.But before removing those lines , I need to ask the user whether user wants to remove the lines. If user inputs "Yes" , the... (3 Replies)
Discussion started by: swapnil.nawale
3 Replies

7. UNIX for Dummies Questions & Answers

Taking a Users input to for the basis of a Grep

Hi I'm currently putting together a script that will grep a set of data for a particular input, specified by the user. I'm getting myself all tangled up with my Echo's and reads. What i'm looking to do is get it so that it prompts the user to enter a value (echo) and then uses their input... (5 Replies)
Discussion started by: Great Uncle Kip
5 Replies

8. Shell Programming and Scripting

Problem taking input from file with for loop

I am trying to take input from a file and direct it into a bash script. This script is meant to be a foreach loop. I would like the script to process each item in the list one by one and direct the output to a file. # cat 1loop #!/bin/bash # this 2>&1 to redirect STDERR & STDOUT to file... (4 Replies)
Discussion started by: bash_in_my_head
4 Replies

9. Shell Programming and Scripting

put an interactive script in background after taking input

i am trying to find a way to put an interactive script in the background after taking input from the user a few test lines i was trying: date echo "Enter location" LOCATION= read LOCATION sleep 100 sleep 200 date for this small example i want the script to as the user for the... (7 Replies)
Discussion started by: epsilonaurigae
7 Replies

10. UNIX for Advanced & Expert Users

Truss taking time in stopping

Hi Experts, I am starting my unix servers with truss cmd and taking truss output in a file . But when I run it for considerabely long time, it is not stopping easily on doing ^C ..... It is taking lotz of ctrl-C's to stop. Please let me know is there any other way to stop truss except ^C and... (1 Reply)
Discussion started by: aarora_98
1 Replies
Login or Register to Ask a Question