reprint the select menu after a selection


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reprint the select menu after a selection
# 1  
Old 06-13-2010
reprint the select menu after a selection

Hi,
I am using a select in ksh for a script
Code:
#!/bin/ksh
FIRSTLIST='one two three four quit'
PS3='Please select a number: '

select i in $FIRSTLIST  ;
do
  case $i in
       one) print 'this is one' ;;
       two) print 'this is 2' ;;
       three) print 'this is 3' ;;
       four) print 'this is 4' ;;
       quit) break  ;;
       *) print 'Invalid selection please try again' ;;
  esac
done

but after the first selection i want the menu to be showed again, not only the PS3 line.
is it possible? (i need it cause i am using select also for sub menus)
I thought of using a go to, or a pointer , but i wasn't manage to do so in ksh.
and i got to use ksh.
please help...
# 2  
Old 06-13-2010
Hi, try:
Code:
...
  esac
  REPLY=
done

# 3  
Old 06-14-2010
thanks,
But it dosent work
# 4  
Old 06-14-2010
Strange, from the ksh93 man page:
Quote:
If the REPLY variable is set to null by the execution of list, then the selection list is printed before displaying the PS3 prompt for the next selection
What does your man page say?
# 5  
Old 06-15-2010
in the man the reply is not mentioned ,but now i am on redhat and it is working!!!
i tested it first on itanium (hp-ux) there it didnt worked.
any ideas why it works in linux and not in unix?

---------- Post updated 06-15-10 at 03:54 AM ---------- Previous update was 06-14-10 at 11:37 AM ----------

just checked it again.
Linux - worked
HP-UX - didn't work
Any suggestions please?
# 6  
Old 06-15-2010
Two suggestions:
1. What happens if you use:
Code:
REPLY=""

2. what happens if you use /usr/dt/bin/dtksh instead of ksh
# 7  
Old 06-15-2010
You can try this we let the results
Code:
#!/bin/ksh
for i in '1)one 2)two 3)three 4)four 5)quit' ; do
   while [ "$i" != "5" ];   do
echo "1) one
2) two
3) three
4) four
5) quit"
print "Please select a number: \c"
read selct
 
case $selct in
       1) print 'this is one' ;;
       2) print 'this is 2' ;;
       3) print 'this is 3' ;;
       4) print 'this is 4' ;;
       5) break  ;;
       *) print 'Invalid selection please try again' ;;
esac
done
        done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Stuck with menu in select

hi i am new to bash scripting .. i created a bunch of folders but only want the folder names with file1. so i go in and make an array to grab the folders the put in a file then i strip the directories so i just have the folder names i need then i would like to make the menu with a selection... (3 Replies)
Discussion started by: lamby22
3 Replies

2. Shell Programming and Scripting

Help with 'select' for menu input

A lot of my scripting makes use of the 'select' command to create menu driven input. A typical example of how I use it is as: somevar='' PS3='Select one: ' while ]; do select somevar in $(sqlplus -s $dbuser/$dbpw@mydb <<EOF set echo off feedback off verify off... (7 Replies)
Discussion started by: edstevens
7 Replies

3. Shell Programming and Scripting

Dialog --menu limitation for the entries for selection

Hi Guys, Please pardon me if this is a silly question, but I have tried to find an answer and going through the man page and failed to get one. I have created a menu driven script with dialog --menu option. Everything is working as expeted, however, it seems that if I have more than 10... (1 Reply)
Discussion started by: ww889
1 Replies

4. UNIX for Dummies Questions & Answers

Dynamic menu selection? Help..

Hi guys, i would like to create a program that allow user to show the information of certain thing such as network card. I would like the menu to be dynamic, for example: my computer system have 2 network card inserted at the moment, therefore the menu will have 2 choice for the user. eth0... (12 Replies)
Discussion started by: malfolozy
12 Replies

5. Shell Programming and Scripting

A selection menu in a shell script

I'm writing a shell script and have a problem with selection when I issue the command, is there a way to automatically choose a selection number one after a selection menue appear Command 1-choice 2- choice 3-choice Thanks Sara (3 Replies)
Discussion started by: Sara_84
3 Replies

6. UNIX for Dummies Questions & Answers

Input A Menu Selection In A Variable

hey all, me again....having a problem with my code, where I essentially am trying to show a menu, have the user select an option (from 1 to 5), then display which selection they picked... #!/bin/bash # A LIST OF THE ERROR MESSAGES AND THE PROPER SYNTAX: error_0="Correct amount of... (1 Reply)
Discussion started by: SoVi3t
1 Replies

7. Linux

Opt out of selection menu?

When I logon to my server with PuTTY I am forced into a selection menu with few options. How to I opt out of this menu to get to the home directory to view all of the files on the server? Thanks for the help. :o (1 Reply)
Discussion started by: ksirimarco
1 Replies

8. Shell Programming and Scripting

Menu help with array selection

Hi there all I got the following I got multiple arrays named for example STAT_AAAA STAT_AAAB STAT_AAAC STAT_AAAD Now what I want I have chosen an option in a menu to select 1 but I dont want to write for all the same thing so I made it a signle one now what I want is to get STAT_ and... (6 Replies)
Discussion started by: draco
6 Replies

9. Shell Programming and Scripting

Select command to build menu

Hello everyone. I am using the select command to build a menu, here is my question: Is it possible to generate a menu which contains several sections and have a separator between the sections without having a selection number generated in front of the separator? This is a sample of what I would... (1 Reply)
Discussion started by: gio001
1 Replies

10. Shell Programming and Scripting

dynamic Select menu

Hi all is menu driven by SELECT can be a dynamic ? My requirement is that i want SELECT to be created on run time not predefine . The select should be created as per the no of words in a file thanks in advance rawat (2 Replies)
Discussion started by: rawatds
2 Replies
Login or Register to Ask a Question