Logging the ^d logoff

Peter J. Holsberg pjh at mccc.UUCP
Sun Feb 14 21:48:01 AEST 1988


In article <7255 at brl-smoke.ARPA> gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
|In article <209 at mccc.UUCP>, pjh at mccc.UUCP (Peter J. Holsberg) writes:
|> One suggestion, which came very close, was to trap 0 1 3 with a line in
|> /etc/profile so that on ^d logout (or hangup, etc.) a line with "who am
|> i" information would be written to /usr/.logins.  I found that this
|> worked quite well except for one thing:  despite the fact that the login
|> time is accurate, the logout time is always about one second after the
|> login time, regardless of the actual logout!
|
|I suspect the only problem is that you forgot that the arguments to the
|"trap" built-in would be evaluated twice, once at the time of executing
|the "trap" built-in, and once (with whatever the result of the first
|evaluation was) when the trap fires at logout time.  Once you realize
|this, the solution is obvious: quote the "who am i" so that it will not
|be evaluated when "trap" is set.

Here's what's in my /etc/profile now:

echo IN: "\t" $LOGNAME "\t" `tty` "\t" `date` >> /usr/pjh/.logins

trap 'echo OUT: "\t" $LOGNAME " \t\c" >>/usr/.logins; `tty` >>/usr/.logins  `date`  >> /usr/.logins' 0 1 3


The 'trap' doesnm't work.  Please suggest modifications.  (I've tried
many but clearly, I've overlooked the one that will work.)  Thx.

-- 
Peter Holsberg                  UUCP: {rutgers!}princeton!mccc!pjh
Technology Division             CompuServe: 70240,334
Mercer College                  GEnie: PJHOLSBERG
Trenton, NJ 08690               Voice: 1-609-586-4800



More information about the Comp.unix.questions mailing list