[Techtalk] Shell script question

Tammy Cravit tammy.lists at warmfuzzy.com
Mon Feb 24 12:02:09 EST 2003

Hi, Jenn,

> fine, except that I don't want people to do a control-c and
> get a shell prompt.  Does anyone know the code to ensure that 

You can put the following at the beginning of your script to stop many
of the common ways people could break out of it:


This will trap control-c (SIGINT) and also will prevent people from
using control-z to suspend the shell script. In the bash shell, the
command "trap -l" will list all of the possible signals that can be
intercepted, and a reading of /usr/include/sys/signal.h usually will
explain what the different signals mean.

You should be aware, though, that there is a brief interval of time
between when the shell starts and when it gets to this point in your
script where a user who's fast could still break out of the shell
script. Something that might work better is to add your script to
/etc/shells (or its equivalent on your system) and then make it your
user's login shell. That way, login starts your script immediately with
no underlying shell process, so if a user manages to control-c out of
it, the system sees that their login shell was terminated, and logs them


More information about the Techtalk mailing list