|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple bash script menu
Dear Sir, May I know how do I go about adding the following feature into the script below: When user enter values other than 1,2,3,4, a) Message “Wrong entry !!! Pls select 1,2,3 or 4” is displayed b) The screen is cleared again and the menu is displayed. Code:
#!/bin/bash clear var=1 until [ $var -eq 4 ] do echo "Menu" echo "(1) Item 1" echo "(2) Item 2" echo "(3) Item 3" echo "(4) Exit" read -p "Enter your choice " var clear echo "Your choice is $var" done I've tried adding * but it returns an syntax error. Thank you. Last edited by Scrutinizer; 01-13-2013 at 04:43 AM.. Reason: code tags |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Hope this helps
Hi Fusetrips, Try using the below its off one of the scripts I already have built. Code:
*) echo "Please select a valid choice "; echo "Press a key to return to the menu. . ." ; read ;; esac : done to the user running the script it looks like the below Code:
Enter your menu choice: 30 Please select a valid choice Press a key to return to the menu. . . once a key has been pressed it returns to the menu Last edited by Scrutinizer; 01-13-2013 at 04:47 AM.. Reason: code tags |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Try using a case statement or an if statement.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help making simple perl or bash script to create a simple matrix | torchij | Shell Programming and Scripting | 16 | 04-26-2012 04:05 AM |
| Simple bash script help | dentex | Shell Programming and Scripting | 2 | 12-27-2010 05:01 AM |
| Help regarding a bash menu script | Vitrophyre | Shell Programming and Scripting | 5 | 04-06-2010 12:55 AM |
| Execute interactive bash menu script in browser with PHP | nck | Shell Programming and Scripting | 1 | 12-14-2009 07:21 PM |
| Bash menu script | AngelFlesh | Shell Programming and Scripting | 3 | 11-29-2009 05:31 PM |
|
|