Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!bloom-beacon!eru!luth!sunic!mcsun!unido!quando!omerzu From: omerzu@quando.UUCP (Thomas Omerzu) Newsgroups: comp.unix.questions Subject: Re: Can the output to a terminal be monitored? Message-ID: <1556@quando.UUCP> Date: 9 Jun 90 10:08:46 GMT References: <2784@syma.sussex.ac.uk> <270@demott.COM> <293@psgdc> Reply-To: omerzu@quando.UUCP (Thomas Omerzu) Organization: Quantum GmbH, Dortmund, W-Germany Lines: 41 In article <270@demott.COM> kdq@demott.COM (Kevin D. Quitt) writes: > >Is there a way that I (as root) can "tap into" a user to monitor >terminal activity? I specifcally would like to do this for the modem line. > I'm using a modified version of the Berkley `script', which was recently posted on the net. That version was intended as a `tutor' support, and sends it output immediately to one ore more terminals. I did some further modifications, which allow to switch monitoring on and off. My approach: The login shell on the modem line is replaced by a modified version of `script', called `bbs0'. It allocates an pty, forks twice for copying in- and output from modem to pty and vice versa, creates a fifo and execs `bbs1' on the corresponding virtual tty. `bbs1' can be any program, e.g. a user menu or a simple shell. At first the copying is only done between pty and virtty. But when I send a SIGUSR1 to the copy processes, they start to duplicate everything they get to the fifo. A `cat < fifo' will show the session on your screen. When you stop the `cat', the copy processes will receive a SIGPIPE and they stop copying to the fifo. This seems to work quite well. The problems reported by bill@twg.UUCP (Bill Irwin) in <165@twg.UUCP> concerning his `tee' version and vi or raw mode seem to not occur. Naturally, the requirement for the same terminal type for monitoring and login session does also apply to this solution. Some problems seem to come up when you have want to use software handshake on the modem line, since `bbs0' requires to set the modem line in raw mode. I did not yet find an appropriate solution for this. -- Thomas Omerzu, omerzu@quando.quantum.de