Case execution problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Case execution problem
# 1  
Old 03-26-2014
Case execution problem

hi guys....in my code the echo statements inside case statements are not printing the required display info....pls help me out

Code:
#!/bin/bash
tput clear
tput cup 3 15
tput setaf 3
echo "BACKUP PROJECT"
tput sgr0
tput cup 5 17
tput rev
echo "select option"
tput sgr0
tput cup 7 15
echo "1.auto Backup"

tput cup 8 15
echo "2.manual Backup"

tput bold
tput cup 12 15

read -p "Enter your choice [1-2]:" choice
case $choice in

1) echo "autobackup" ;;
2) _zenity="/usr/bin/zenity"
 SOUR_PATH=$(${_zenity} --title "Enter source path"\
                        --entry --text "Enter the source pathe to backup" )
tput clear
tput setaf 3
tput cup 5 17
tput rev
echo "Select Destination"
tput sgr0
tput cup 7 15
echo "3.local"

tput cup 8 15
echo "4.Remote"

tput bold
tput cup 12 15

read -p "Enter choice:" choic
case $choic in

3) echo "local destinaion";;
4) echo "remote destintion";;
esac
;;
esac

# 2  
Old 03-26-2014
A couple of possible problems here. The last two lines
Code:
;;
esac

... are unnecessary.

The read -p is trying to read from a pipe, not from the screen. If this were ksh I would suggest changing it to say:-
Code:
read choice?"Enter choice:"
case $choice in
   3) echo "local destination"     ;;
   4) echo "remote destination"    ;;
   *) echo "unknown destination"  ;;
esac

... but I'm not sure what bash willl support or if my suggesting is superseded by better bash coding.


I hope that this helps,
Robin
Liverpool/Blackburn
UK
# 3  
Old 03-26-2014
Thread moved to shell... Do not post in Contact admins!
# 4  
Old 03-26-2014
Sorry it did not solve my problem.....and
Code:
read -p

is required to read from tput
# 5  
Old 03-26-2014
What is the issue? Or what is not printed? But the best would be you explain what it should display...
# 6  
Old 03-26-2014
when a choice is provided....the echo statement for that particular choice is not executing.
# 7  
Old 03-26-2014
Funny it seem to work here...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem

How to search a pattern from multiple files... i used the command suppose the pattern name is xxx grep xxx (file1-o- file2-o- file3) Thanks in advance (4 Replies)
Discussion started by: ksakil
4 Replies

2. Shell Programming and Scripting

Execution problem

Hi, I have been trying to run a simple script CONFIG_FILE="/jay/check" . . . for i in `cat $CONFIG_FILE` do loc=`echo $i | cut -d "|" -f2` var=$(find $loc -mtime -1|wc -l) if then echo $loc has files older than 1 day fi done . . . (2 Replies)
Discussion started by: jayii
2 Replies

3. Shell Programming and Scripting

problem with case

hello everyone.. i want to make a file which, when u run it, it asks for your name and how many times you want to see your name displayed.. the program ever 10 times it will ask you if you want to continue and u have to answer with Y or N. if you type Y it continues displaying your name from where... (8 Replies)
Discussion started by: Telis
8 Replies

4. Shell Programming and Scripting

Execution problem

hi all, when i tried executing the script by giving following command $ sh test.sh <parameter> it shows the following output: <none> status code=0 Previously it was working fine.But now its showing this output. (1 Reply)
Discussion started by: sanjay mn
1 Replies

5. UNIX for Dummies Questions & Answers

execution problem

HI I am trying to check the status of port using command /code: netstat -an | grep port /Output: *.2009 *.* 0 0 65535 0 LISTEN what i am trying to do is i want to grep only status Wether the port is established/listen if so show ok else... (1 Reply)
Discussion started by: esumiba
1 Replies

6. UNIX for Dummies Questions & Answers

execution problem

Hi I am automating my few commands out of which one command is tail -f running.logs when i run this command it does not automatically exit and show prompt (#) what would i do so that it will exit out automatically after few seconds and move to the next command without using ... (4 Replies)
Discussion started by: esumiba
4 Replies

7. UNIX for Dummies Questions & Answers

execution problem

Hi i have a file in which there are three fields code: 919804199233 404911130003916 357266044991350F and now i want to add two more fields i.e. code: 919804199233 404911130003916 357266044991350F ms 123 how can i do it using command line and if have a file of 100... (8 Replies)
Discussion started by: esumiba
8 Replies

8. UNIX for Dummies Questions & Answers

execution problem

Hi i am using expect module and trying to login using following code. ssh 127.0.0.1 expect "word:" send "$password \n" kindly let me know the login script using expect module (1 Reply)
Discussion started by: esumiba
1 Replies

9. Shell Programming and Scripting

Execution problem on kornshell

HI, Requirement: I need to pass space between argument value for the paramter "GPG_PUBLIC_UID" but whenever i use single quotes or double quotes while supplying value for the arguments to the script, i see the value of the field "GPG_PUBLIC_UID" is getting splitted and my script fails to... (6 Replies)
Discussion started by: reachaysh
6 Replies

10. Shell Programming and Scripting

Problem using 'Case' statement

Hi, When I execute the below script, I am getting the error as ' is not expected.ror at line 3 : `in #!/bin/sh case $1 in -r) echo Force deletion without confirmation ;; -i) echo Confirm before deleting ;; *) echo Unknown argument ;; esac I could not see any problem with... (1 Reply)
Discussion started by: Sathish_Obla
1 Replies
Login or Register to Ask a Question