Xref: utzoo comp.sys.att:2290 comp.unix.questions:5322 Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.sys.att,comp.unix.questions Subject: Re: Using 'exit' in a Bourne shell script Summary: use a shell function Message-ID: <611@cresswell.quintus.UUCP> Date: 30 Jan 88 09:47:59 GMT References: <169@mccc.UUCP> Organization: Quintus Computer Systems, Mountain View, CA Lines: 26 In article <169@mccc.UUCP>, pjh@mccc.UUCP (Peter J. Holsberg) writes: > I would like to have my users logout via a shell script "off" rather > than with ^d. > Can anyone suggest a way (SysVr3.0) to do what I want? Thanks. Don't use a script. Use a shell function. Then it'll be running in the login shell. By the way, there is a potential surprise anyway: login: user-logs-in $ ed myfile !off Here we have login shell-->ed-->subshell, and you can't log out of the subshell. Since you are writing records to a log file, presumably you do something like this on login: echo ON $USER `tty` >>logfile Do one more thing: echo $$ON $USER `tty` Now to logout, you can do echo OFF $USER `tty` >>logfile CODE="ON $USER `tty`" kill -HUP `egrep -e "$CODE$" logfile | tail -1 | sed -e "s/ON.*//"` This should work from a subshell.