Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New problem with menu timeout 1

Status
Not open for further replies.

lpblauen

Technical User
Dec 2, 2004
193
US
Thanks to the many suggestions I got the menu program working. It times out right and even ctrl-c logs the user out. Now the new problem. From the main menu We call other scripts then return to the main menu. The problem is if we type a wrong option we get invalid option but then if we ctrl-c we drop to a prompt. If we go to a option and it returns to the main menu it doesn't timeout and ctrl-c drops to a prompt. Ideas??? here is the main menu:

# Name: helpmenu
clear
trap 'print "Problem with Help Desk menu"; exec kill -9 $PPID' HUP INT QUIT STOP
TIMEOUT=120

while
print " Helpdesk Menu Options"
print " 1) Add users"
print " 2) Change password"
print " 3) Check printer status"
print " 4) Delete printer jobs "
print " 5) Reset printer "
print " 6) Show users on the system"
print " 7) Show an account"
print " 8) Clean up IP address"
print " 9) Logout "
print
(sleep $TIMEOUT; kill -15 $$ >/dev/null 2>&1) &
do read SEL?" Option: "; RC=$?
kill -9 $! >/dev/null 2>&1
case "$SEL" in
1) . set_accounts ;;
2) . newpass ;;
3) . checkprint ;;
4) . deletejob ;;
5) . reset_queue ;;
6) . showusers ;;
7) . show_account ;;
8) . netfix ;;
9) return ;;
*) print
print "Invalid Option ${SEL}, please try again!" ;;
esac
done

Here is one of the sub menus scripts called showusers:

# Name: Showusers
#
trap 'print "Problem with Showusers program "; return' HUP INT QUIT STOP
node=$(hostname -s)
print " "
print " Current users on " $node
print " "
who -uH
print " "
print " "
return

 
I haven't tried running it so I'm not really sure this is it, but you are sourcing the sub-menus ("[tt]. showusers[/tt]"). That means your [tt]trap[/tt] command in those sub scripts actually changes the trap command in [tt]helpmenu[/tt]. You never set it back to what it should be in [tt]helpmenu[/tt]. Maybe take the [tt]trap[/tt] command out of the submenu, or move [tt]helpmenu[/tt]'s [tt]trap[/tt] command into the [tt]while[/tt] loop so it gets set again after returning.
 
That did it. Thanks I moved the while before the trap in the main menu program and now when I go to a sub menu and back ctrl-c will logout the user and the menu times out again after 15 minutes where after going to a sub menu the timeout broke. Thanks again......
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top