Menu function stuck in a loop?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Menu function stuck in a loop?
# 1  
Old 12-14-2001
Menu function stuck in a loop?

I having problem when I call this cleanupmenu function within a script. It continuously loops and goes to selection * That wasn't a valid selection. I have to kill it everytime to stop it. What am I doing wrong. I use this function menu in several other scripts and I don't have this problem at all. Also, when I don't use this menu as a function and put it at the end of this script it does the same thing.

#!/bin/ksh
#
realname=` who -m | awk '{print $1}'`
#
# Create Cleanup Choice Menu Function
#------------------------------------------------------------------
cleanupmenu ()
{
echo " $realname Choose your Options"
echo " "
echo "1. Review Queue script before execution "
echo "2. Execute Script on $QMGR"
echo " "
echo "x Exit Menu "
echo "--->\c" | tee -a $LOG
read
case $REPLY in
1 ) page $QL_LOG3 ;;
2 ) runmqsc $QMGR < $QL_LOG3 | tee -a $LOG ; echo " Exiting ..Goodbye $realname!" ;;
x|X ) echo " Exiting ..Goodbye $realname!" ; break;;
* ) echo "$realname That wasn\'t a valid Menu Selection! Try Again." ; sleep 1 ;;
esac
}

echo "Hello $realname" | tee $LOG

echo "$realname - What Queue Manager would you like to use?: \c" | tee -a $LOG
read QMGR
echo "You chose $QMGR" | tee -a $LOG

echo "extracting amq3 file names"
sleep 1
print "dis ql(AMQ.3*);" | runmqsc $QMGR >$QL_LOG1
awk /QUEUE/ $QL_LOG1 | cut -f2 -d\( | cut -f1 -d\) | sort >$QL_LOG2

exec < $QL_LOG2
while read line ; do
echo 'delete qlocal('${line}')' >>$QL_LOG3
done

cleanupmenu
# 2  
Old 12-14-2001
Re: Menu function stuck in a loop?

Quote:
Originally posted by darthur


exec < $QL_LOG2
while read line ; do
echo 'delete qlocal('${line}')' >>$QL_LOG3
done

cleanupmenu
With that exec statement you set the script's standard-in to a file. Then with that loop you read all the data. At this point, standard-in is at end-of-file. Then you call cleanupmenu which contains a read statement. That read statement will try to read one more line from the $QL_LOG2 file but it won't succeed. You need to add
exec < /dev/tty
before you invoke cleanupmenu to put standard-in back to being the tty.
# 3  
Old 12-14-2001
MySQL exec < /dev/tty fixed it

Thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 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

Execute function as soon as input is provided in menu drive shell script

Hi All, I have a menu driven scripts. As you know while running the script we have to input the option such as 1,2, and 3 to execute function accordingly. but after selecting the input we have to press Enter. My requirement is to execute function as soon as we press the option. Is there... (5 Replies)
Discussion started by: kiran_j
5 Replies

3. Shell Programming and Scripting

Special case to skip function in bash menu

In the bash menu below if the variant that is inputted is in the format NM_004004.3:c.274G>T the below works perfectly. My question is if the variant inputted isNM_004004.3:-c.274G>T or NM_004004.3:+c.274G>T then the code as is will throw an error due to a biological issue. Is it possible to to... (1 Reply)
Discussion started by: cmccabe
1 Replies

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

5. Shell Programming and Scripting

Noob stuck - where do I put my loop

I'm a noob working on a script to take 3 user inputs. One of them is simply a variable: "poolname". The other 2 are cases: "groupa/groupb" and "enable/disable". "groupa" and "groupb" reference 2 files - groupa.txt or groupb.txt. These files simply consist of a list of server IP addresses and port... (2 Replies)
Discussion started by: *nixnoob
2 Replies

6. Shell Programming and Scripting

perl loop keeps getting stuck

I am using a Perl script to open a series of files in a loop, separate the paragraph into lines, and output the lines into a new file. The code works perfectly fine, except when the source file is over a certain size the loop gets stuck and won’t move on to the next file. It still does what it is... (0 Replies)
Discussion started by: renthead720
0 Replies

7. Shell Programming and Scripting

Script Stuck In Loop

Hi all! Im trying to get this script to check for folders in a year/month/day folder structure and if the day doesnt exist then it makes the day. It will also make sure all of the days before todays date exist as well. This script assumes that the month and year folder already exist. It works... (3 Replies)
Discussion started by: Grizzly
3 Replies

8. Shell Programming and Scripting

My menu function [new code -revised]

Below is my menu options code. It allows user to pick one of two option. I can get the first option to work, because if it is selected it just "breaks" and carries on with the script. What i want to know is if a user selects option two how do i get that option to ignore all the other script and... (3 Replies)
Discussion started by: amatuer_lee_3
3 Replies

9. Shell Programming and Scripting

My menu function

Below is my menu options code. It allows user to pick one of two option. I can get the first option to work, because if it is selected it just "breaks" and carries on with the script. What i want to know is if a user selects option two how do i get that option to ignore all the other script and... (6 Replies)
Discussion started by: amatuer_lee_3
6 Replies
Login or Register to Ask a Question