multiples menu in ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multiples menu in ksh
# 1  
Old 06-26-2010
multiples menu in ksh

Hi,

IS possible in ksh to make multiples menus?

For example:

Code:
My menu.
1)Option1
   1.1)Option1.1
   2.3)Option1.2
2)Option2
  2.1)Option2.1
.
.
.
x)Exit

I've tried with case but no success.

Thanks in advance.
Israel

Last edited by Scott; 06-27-2010 at 06:28 AM.. Reason: Code tags, please...
# 2  
Old 06-26-2010
Styled after IBM S36 menus and a DOS shareware program called Automenu.
# 3  
Old 06-27-2010
If you are using ksh93, the select keyword is for creating menus. Here is the relevant except from ksh94 man page.

select vname [ in word ... ] ;do list ;done

A select command prints on standard error (file descriptor 2) the set of words, each preceded by a number. If in word... is omitted, the positional parameters starting from 1 are used instead. See Parameter Expansion. The PS3 prompt is printed and a line is read from the standard input. If this line consists of the number of one of the listed words, then the value of the variable vname is set to the word corresponding to this number. If this line is empty, the selection list is printed again. Otherwise the value of the variable vname is set to null. The contents of the line read from standard input is saved in the variable REPLY. The list is executed for each selection until a break or EOF is encountered. If the REPLY variable is set to null by the execution of list, the selection list is printed before displaying the PS3 prompt for the next selection.
# 4  
Old 06-27-2010
example:

Code:
#!/bin/ksh

echo "Hello"
echo "Please select a chioce:"

PS3="Choose a number: "
CHOISE='one two three quit'
select i in $CHOISE
do
  case $i in
        one)  echo "selected one";;
        two)  echo "selected two";;
      three)  echo "selected three";;
       quit)  exit;;
          *)  echo "\nInvalid Choice\n";;
  esac
done

You can also add submenus inside a case
in Linux in the end if you add
Code:
REPLY=

it will re prompt the menu.
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

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

3. Shell Programming and Scripting

KSH- perform a function if user selects option from menu

Hi, I have a script that copies a file from one directory to another and compiles it. What I have now is a menu that calls functions and each function compiles the file. I want to have a function that compiles the file at the end of the script if the user selects options 1-3 in the menu, but... (0 Replies)
Discussion started by: amitlib
0 Replies

4. Shell Programming and Scripting

Select ksh menu question

I am creating a Select menu with a few options and I would like to create a "better" looking interface than just this: 1) Option 1 2) Option 2 3) Option 3 Instead, I would like something like this: *********** * Cool Script * * 1) Option 1 * * 2) Option 2 * * 3) Option 3 *... (2 Replies)
Discussion started by: chipblah84
2 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. Programming

multiples of 10 in java

Hi Guys, I wonder how can I determine when a given number is a multiple of another one in java. Let's say if I have 27 how can I determine whether is multiple of 5 using java programming. Thanks. (1 Reply)
Discussion started by: arizah
1 Replies

7. Programming

Pointer addresses in multiples of 32 ?

1. Why are the pointers' addresses every 32 ? 2. Am I correct in stating that memset is writing to memory that is not allocated to any of the 3 pointers ? Is it writing to memory in between the pointers ? 3. Are the 3 pointers contiguous in memory ? 4. I only allocated 10 bytes for each pointer.... (5 Replies)
Discussion started by: cyler
5 Replies

8. Shell Programming and Scripting

KSH Setting multiples variables with an array

ih all, info=$(get_Info $daemon) # $info give : # "ev20 8800 TTIOGC 12345 astos EDITEUR 0 0 . ." server=$(echo $info | cut -d" " -f1) port=$(echo $info | cut -d" " -f2) dname=$(echo $info | cut -d" " -f3) dport=$(echo... (1 Reply)
Discussion started by: wolfhurt
1 Replies

9. UNIX for Advanced & Expert Users

Menu driven using Ksh

Hi Guys, I would like to know how to write Menu driven programs using ksh. I have several script files 1.sh 2.sh 3.sh ...so on 25 files I want to create a Menu which will calls submenus. Main Menu 1. Data Entry if you press 1 again submenu 1. Order entry ... (3 Replies)
Discussion started by: krishna
3 Replies
Login or Register to Ask a Question