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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I disable the delete key

Status
Not open for further replies.

lorel

MIS
Jun 15, 2004
158
Hello there:

I have to create a user which will be limited to run one script then exits out. The user has been created and so is the script. While testing the user can hit the delete key which will terminate the script and dump the user to a $ sign.

I need to trap or disable the delete key to prevent the user from dropping to the $ sign, I either need for the user not to leave the script or to be exit out (logoff) when he/she hits the delete key.

I know that this can be done, I have done it myself, but that was long time ago and can not seem to remember how I did it.

This must be done so only affects this user and no one else.

Can anyone help?

Thanks

Joe
 
Change that user's login script "/usr/USERNAME/.profile" to "exec" your script. If they exit the script, their session ends.

man exec



"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
The scrip is run from the .profile of the user followed by an exit command. This will logoff the user the moment they hit the option to exit.

To solved the problem of the delete key, I did the following:

At the beguining of the script I added
OLD=`stty -g`
stty intr '^-'

At the end of the script, following the option to exit, I added
stty $OLD
This resolved my problem.

Thanks to Fonseca and to motoslide for your help!

Joe
 
I tried using exec, and it worked better, so I removed the stty related code and just run the script using exec.

Thanks guys!

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top