Using 'exit' in a Bourne shell script

Kathy Vincent kathy at bakerst.UUCP
Sun Jan 31 18:04:54 AEST 1988


In article <169 at mccc.UUCP> pjh at mccc.UUCP (Peter J. Holsberg) writes:
>I would like to have my users logout via a shell script "off" rather
>than with ^d.  The script I wrote is very simple, but 'exit' has no
>effect. ...
>
>The correct entries appear in /usr/.logins, but 'exit' seems to be
>ignored.  


The exit in your shell script is only going to get you out of that
script.  In fact, sending exit codes is one way of communicating between
scripts ( if [ script exits with a number "n" ] then ...).

A friend of mine solved that problem thusly.  He was only interested
in his own .profile, but

	trap '$HOME/.logout' 0

Which is to say, "when you receive the logoff signal, execute $HOME/.logout
first and THEN log off."  I believe there's probably a problem with this,
though:  Traps can be reset, so a user could, as I understand it, ask to
have something else happen at signal 0 , thereby negating what you're
trying to do.  Someone correct me if I'm wrong about this (I'm sure
someone will) 'cuz I'd like to know.


Kathy Vincent ------>  {ihnp4|mtune|codas|ptsfa}!bakerst!kathy
              ------>  {ihnp4|mtune|burl}!wrcola!kathy
              ------>  { favourite AT&T gateway }!wruxe!unix



More information about the Comp.unix.questions mailing list