Path: utzoo!utgpu!water!watmath!clyde!rutgers!ukma!gatech!udel!princeton!mccc!pjh From: pjh@mccc.UUCP (Peter J. Holsberg) Newsgroups: comp.unix.questions Subject: Re: Logging the ^d logoff Message-ID: <213@mccc.UUCP> Date: 14 Feb 88 11:48:01 GMT References: <209@mccc.UUCP> <7255@brl-smoke.ARPA> Reply-To: pjh@mccc.UUCP (Peter J. Holsberg) Organization: The College on the Other Side of US Route 1 Lines: 31 In article <7255@brl-smoke.ARPA> gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: |In article <209@mccc.UUCP>, pjh@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