The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
My menu function [new code -revised] amatuer_lee_3 Shell Programming and Scripting 3 05-18-2008 04:05 AM
My menu function amatuer_lee_3 Shell Programming and Scripting 6 05-17-2008 07:19 PM
stuck....! moxxx68 UNIX for Advanced & Expert Users 0 12-10-2004 07:52 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 08:09 AM
Endless loop - Fork function failed? cdunavent Shell Programming and Scripting 3 01-30-2002 09:12 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-14-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
Stumble this Post!
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
Forum Sponsor
  #2 (permalink)  
Old 12-14-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,425
Stumble this Post!
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 (permalink)  
Old 12-14-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
Stumble this Post!
Thumbs up exec < /dev/tty fixed it

Thanks!
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0