Creating a menu


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating a menu
# 1  
Old 02-06-2008
Creating a menu

Hi,
I need your help co create a very small menu somthing that look like this:

1. first step
2. second step
3. last step
from step : ___
to step : ___

If the user choose 1 --> it will echo : Hellow
If the user choose 2 --> it will echo : World
If the user choose 3 --> it will echo : Bye
If the the user choose from 1 to 2 --> it will echo : Hello
World
And so on.

Thank you very much for your help.
# 2  
Old 02-06-2008
Code:
echo 1. first step
echo 2. second step
echo 3. last step
echo 4. from step:_ to step:

FIRST=hello
SECOND=WORLD
LAST=Bye

read CHOICE
case $CHOICE in
 1) echo $FIRST ;;
 2) echo $SECOND ;;
 3) echo $LAST ;;
 4) read -p step1: ONE; read -p step2: TWO

      case $ONE$TWO in
       11) echo $FIRST ;;
       12) echo $FIRST $SECOND ;;
       13) echo $FIRST $SECOND $LAST ;;
       22) echo $SECOND ;;
       23) echo $SECOND $LAST ;;
       33) echo $LAST ;;
      esac

esac

# 3  
Old 02-06-2008
The program 'dialog' does a good job of this type of work it seems:

Dialog: An Introductory Tutorial
# 4  
Old 02-07-2008
Creating Menu

Hi ,
I runed the code above. if i choose just one option its work fine.
But if i choose to run it between two option its retun nathing.
For example:

/software >./tafrit.sh
1. first step
2. second step
3. last step
4. from step:_ to step:
2
WORLD

/software >./tafrit.sh
1. first step
2. second step
3. last step
4. from step:_ to step:
12
/software >

Thanks.
# 5  
Old 02-08-2008
hm you are right, doesn't work, somethings wrong with the semicolons

this one should work:

Code:
echo 1. first step
echo 2. second step
echo 3. last step
echo 4. from step:_ to step:

FIRST=hello
SECOND=WORLD
LAST=Bye


FROMTO()
 {
      case $ONE$TWO in
       11) echo $FIRST ;;
       12) echo $FIRST $SECOND ;;
       13) echo $FIRST $SECOND $LAST ;;
       22) echo $SECOND ;;
       23) echo $SECOND $LAST ;;
       33) echo $LAST ;;
      esac
 }

read CHOICE
case $CHOICE in
 1) echo $FIRST ;;
 2) echo $SECOND ;;
 3) echo $LAST ;;
 4) read -p step1: ONE; read -p step2: TWO; FROMTO;;



esac

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Gnome 3.28.3 menu item dissapears under the system menu

I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome. Unfortunately, I never found a... (1 Reply)
Discussion started by: bodisha
1 Replies

2. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

3. Shell Programming and Scripting

Need help creating a menu.

Hi Master of masters, Thanks for ur reply. Need ur help for following. Is it possible to create menu for following in linux or a function. > Look in logs > Status > Action > End Action > CONFSUCCESS > Success > Show message as successful > Enter to continue > CONFFAIL > Failure > Show... (1 Reply)
Discussion started by: rajeshwebspere
1 Replies

4. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

5. Shell Programming and Scripting

Menu in Menu script issue

Problem: I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Discussion started by: iDdraig
1 Replies

6. Shell Programming and Scripting

Creating a menu from find

Hi I am wanting to create a menu that will list all the log files in a specific directory such as /apps/logs. So it would be something like this: #!/bin/ksh print 'Select The Required Log File' PS3='log? ' select choice in <this is to contain a list of files that are in a directory that... (3 Replies)
Discussion started by: markrj
3 Replies

7. Shell Programming and Scripting

Creating a menu within a script file

I am very new to Unix and know the basic commands. I have to write a script file and I'm completely lost. The script file is to show the following at the beginning: Menu of Options 1. Display all files in a user's home directory. 2. Welcome yourself to the program. 3. Display System... (8 Replies)
Discussion started by: sinjin
8 Replies

8. Shell Programming and Scripting

Creating menu list from configuration file

Hi folks, I have the following function ,which generates menu for installation type: select_install_type() { echo echo ======================================== echo Please select the type of installation: echo ======================================== ... (8 Replies)
Discussion started by: nir_s
8 Replies

9. Shell Programming and Scripting

creating a menu for recycling and permanently deleting files.

Trying to alias rm to move files to a hidden trash directory in the bash shell. I've tried to create this alias numberous ways and it's just not working. Here's what I've tried, anyone have any suggestions. alias rm='mv $* ~/.trash' alias rm= 'mv$* ~/.trash' things like that... I've also... (2 Replies)
Discussion started by: strmy_ngts
2 Replies
Login or Register to Ask a Question