Computing.Net > Forums > Unix > Traping Ctrl-Z in KSH Shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Traping Ctrl-Z in KSH Shell script

Reply to Message Icon

Name: vs
Date: July 1, 2003 at 04:10:00 Pacific
OS: SunOs 5.6
CPU/Ram: 2GB
Comment:

Hi,

I am writing a shell script to accept input from user and upload the data files using sqlloader. I want to trap Ctrl-Z which is SIGTSTP so that user do not come out of the shell script using Ctrl-Z key. I could successfully capture Ctrl-C key with following command
trap 'echo "Invalid Keys Pressed" ' INT
but Ctrl-Z key can not be trapped. Can any one give me the way around to stop user coming out of the shell script by Ctrl-Z?

Thanks in Advance



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: July 1, 2003 at 07:26:28 Pacific
Reply:

Hi:


Some Unix variants (Sun and SCO), suspend a job, by default, using control-z. I don't know of a way of trapping the control-z, but you can disable job control.

Execute stty -a

and among other things you should see:

susp=^z

In the login process (.profile or /etc/profile), install this:

stty susp ""

and that should release control-z. Obviously, if you have a user that requires job control, you can't do this or pick something other than control-z.

Regards,

Nails


0

Response Number 2
Name: vs
Date: July 2, 2003 at 03:50:06 Pacific
Reply:

Thanks Nails

The .profile option works. I was not successful using the other 2.

regds,


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Traping Ctrl-Z in KSH Shell script

ftp sql results in shell script www.computing.net/answers/unix/ftp-sql-results-in-shell-script/6338.html

Please HELP in shell script www.computing.net/answers/unix/please-help-in-shell-script-/3266.html

Auto say y or n in a shell script www.computing.net/answers/unix/auto-say-y-or-n-in-a-shell-script/4059.html