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!

trap CTRL-C in called scripts 1

Status
Not open for further replies.

AlbertAguirre

Programmer
Nov 21, 2001
273
US
I am setting "trap "" 1 2 3" at the top of the main script. I am trying to stop users from doing a CTRL-C out of the script onto the command line.

The mainscript has a menu that calls other scripts, but the user can CTRL-C out of these called scripts.

How do I avoid this without having to set the trap in every script that is called from the main script?

Thanx in advance
 
You may change the intr character with stty on top of the mainscript, resetting it when exit

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Youre a genius!

I'm doing the following:
oldstty=`ssty -g`
stty intr "~"
run script menu
stty $oldstty

One question, I am setting the interrupt to a key that I dont think they will press, the squiggly "~"

How can I disable it? Just "" ?
 
stty intr '^-'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top