menu selections


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting menu selections
# 1  
Old 03-03-2009
menu selections

I am trying to find a way to allow users to select multiple options in a shell menu. I am using case and it gives menu options 1-9, how can I set this up so that it give the user the ability to choose more then one option, ie 1,2 or 3,4,5, etc...
# 2  
Old 03-03-2009
hi,

giving multiple options to select is a little tricky. This is what you can try:
in your case, have 'q' to quit selection, and until 'q' is selected, loop to display menu, for every selection that is made, save it in an array.

Hope I was clear this helps.

Regards,
Kunal parmar
# 3  
Old 03-03-2009
Quote:
Originally Posted by parmar.kunal
hi,

giving multiple options to select is a little tricky. This is what you can try:
in your case, have 'q' to quit selection, and until 'q' is selected, loop to display menu, for every selection that is made, save it in an array.

Hope I was clear this helps.

Regards,
Kunal parmar

I think I understand, but do you have any examples? Is there an industry name for this type of operation?
# 4  
Old 03-03-2009
Code:
printf "%s\n" "MENU" "  1. qwerty" "  2. uiop" "  3. asdf" "  4. ghjkl"
printf "%s: " "Your choice (separate multiple selections with a comma)"

read selection

selection=$selection,
while [ -n "$selection" ]
do
   opt=${selection%%,*}
   echo "You selected: $opt"
   selection=${selection#*,}
done

# 5  
Old 03-03-2009
Thanks! I will give this a try in a bit.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 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

How to automate user menu selections?

Hello all, I am sort of new to Shell programming and to this forum. I want to create a script that auto selects menu options. lets say I have a menu. MAIN MENU 1.) opt1 2.)opt2 3.)opt3 I want the script to automatically select option 1. (6 Replies)
Discussion started by: gerry8a
6 Replies

3. 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

4. Shell Programming and Scripting

Menu with sub-menu options

Hi! I have created on script which is working fine with menu options and with a sub-menu. I want to enhance it by using sub-options under menu options. Like. option 1) will give the list only. option 1.1) should give the option to user to choose one file, whose content user wanna see. ... (3 Replies)
Discussion started by: sukhdip
3 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

Adding New Selections to the existing Script

Hi.... i have two scripts called: "type" & "selecttype". In "type" i have only the name of the products ex.: product1 & product2. Now, i have to ADD product3 which includes sub categories: productA, productB, productC, productD, productE, productF. so my New type script (menu) looks as... (1 Reply)
Discussion started by: Netrock
1 Replies

7. Shell Programming and Scripting

Menus in Korn Shell and invalid selections

Hey Guys. I need to code a series of menus that have four options, selectable either by the number in the menu or the name, in succession. This part I have achieved however I am struggling to find a way that should the user try to enter an invalid selection, such as the number 5 or an incorrect... (5 Replies)
Discussion started by: Mudja
5 Replies
Login or Register to Ask a Question