LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-21-2011, 04:14 AM   #1
Batistuta_g_2000
Member
 
Registered: Oct 2011
Posts: 85
Blog Entries: 1

Rep: Reputation: Disabled
Linux menu won't work - case statement


Can anyone help me, am new to linux have menu to pick from three options; i want it to close and load another shell script if option one or two - else exit:


#!/bin/sh
#
############## Menu for Backup and Restore Options ######################
#
while :
do
clear
echo "_______________________________________"
echo " MAIN BACK MENU "
echo "_________________________________________"
echo " "
echo " [1] Backup a File or Directory"
echo " [2] Restore a File or Directory"
echo " [3] Exit"
echo " "
echo "_________________________________________"
echo " "
echo " "
echo " "
echo -n "Enter your menu choice [1-3]"
read yourch

case $yourch in




1)
clear


echo "________________________________"
echo "_______BACKUP MENU_____________"
echo ""
cd /home/ubuntu/
backup start ;read;;

2)
clear


echo "________________________________"
echo "_______RESTORE MENU_____________"
echo ""
cd /home/ubuntu/
restore ;read;;



3) exit 0 ;;
*) echo "Opps! Please select an option 1,2 or 3";
echo "Press a key..."; read ;;
esac




done
 
Old 10-21-2011, 04:36 AM   #2
phaemon
Member
 
Registered: Jul 2011
Posts: 40

Rep: Reputation: 5
Well, you haven't said what isn't working or what you're trying to do (that's why you should have comments in your script!), but I'm guessing it doesn't run the "backup" or the "restore" scripts, which are ones that are in your /home/ubuntu directory?

You probably need to have the full path, so rather than using "cd", just run "/home/ubuntu/backup" and "/home/ubuntu/restore"

Also, why do you have a "read" after? Don't you just want to exit after they've chosen a valid option?
 
Old 10-21-2011, 04:36 AM   #3
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 106Reputation: 106
You can embed it in the script or set the path to the next script in the script.
 
1 members found this post helpful.
Old 10-21-2011, 04:56 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
May I also suggest having a look at what a here document is and maybe also select.
 
1 members found this post helpful.
Old 10-21-2011, 05:59 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Does this have to be a posix-compliant script (#!/bin/sh), or can you use bash or another shell? It affects what features can and can't be used.

Also please use [code][/code] tags around your code, to preserve formatting and to improve readability. (And note that quote tags are not for code either.)
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl switch statement throwing error like Bad case statement (invalid case value?) kavil Programming 2 10-07-2010 04:50 AM
Case Statement craigjward Programming 6 12-12-2007 11:33 PM
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 08:05 PM
case statement baks Programming 2 03-15-2007 01:19 PM
bash'ed by case statement??? 3inone Programming 2 04-29-2004 04:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration