UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 6th, 2005, 08:43 PM
anzix anzix is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 4 anzix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 17 sec
Reputation Power: 0
Loop a menu?

Hello,
I have been learning shell scripting for about a week. I created a menu that allows you select options but when an option is seleted it terminates the script how would I loop the option to go back to the menu.

For the menu i am using the case function.

Code:
case $choice in
 1) whoison     # calls the e-mail function
       ;;
 2) thecal      # calls the whoison function
    ;;
 3) whereami      # calls the thedate function
    ;;
 4) changedir    # changes the directory
    ;;
 5) listfiles    # lists files in current directory
    ;;
 6) thedate     # displays the date & time
    ;;
 7) startvi      # starts vi
    ;;
 8) theemail     # start e-mail
    ;;
 9) echo "Thank you for running this program!";
    exit 0
    ;;
 *) echo "Invaild option; try running the program again.";
    exit 0
       ;;
 esac

Reply With Quote
  #2  
Old June 13th, 2005, 09:13 AM
zlutovsky zlutovsky is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Prague, Czech Rep.
Posts: 117 zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 42 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by anzix
Hello,
I have been learning shell scripting for about a week. I created a menu that allows you select options but when an option is seleted it terminates the script how would I loop the option to go back to the menu.

For the menu i am using the case function.

Code:
case $choice in
 1) whoison     # calls the e-mail function
       ;;
 2) thecal      # calls the whoison function
    ;;
 3) whereami      # calls the thedate function
    ;;
 4) changedir    # changes the directory
    ;;
 5) listfiles    # lists files in current directory
    ;;
 6) thedate     # displays the date & time
    ;;
 7) startvi      # starts vi
    ;;
 8) theemail     # start e-mail
    ;;
 9) echo "Thank you for running this program!";
    exit 0
    ;;
 *) echo "Invaild option; try running the program again.";
    exit 0
       ;;
 esac



Hello,

put your case statement into an endless loop like this:

while :
do
# your case
done

In your case statement the oprion "9" will end the loop.

Regards

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Loop a menu?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway