# Can I get realtime output of another users terminal?



## isolder (Dec 1, 2003)

Been playing around with remote login on my mac using putty on my windows computer.  Tried doing the talk command between ttyp1 and ttyp2, but connection/invitation would never get made..

Wanted to be able to see if I could view another terminals output/input in an almost realtime fashion?  I thought there was a way to do this.. am sure I've read something about it, but can't find the command.


----------



## btoneill (Dec 1, 2003)

The only way you can do something like this is using the "screen" command. You can have multiple people connect to a screen "session". Take a quick look at http://www.mkaz.com/reference/unix_screen.html.

Brian


----------



## isolder (Dec 1, 2003)

The only way? for sure?

What about not so realtime, just something that echoed(?) another user's commands to my window as he typed them?  It must be possible because there are logs of commands that users last typed, right?

In the Cuckoo's Egg (by clifford stoll) he was able to keep a record of every command the hacker typed.  Now I realize this is a different system altogether but I can't see there not being some sort of built in command to do this..


----------



## dafuser (Dec 2, 2003)

isolder said:
			
		

> The only way? for sure?
> 
> What about not so realtime, just something that echoed(?) another user's commands to my window as he typed them?  It must be possible because there are logs of commands that users last typed, right?
> 
> In the Cuckoo's Egg (by clifford stoll) he was able to keep a record of every command the hacker typed.  Now I realize this is a different system altogether but I can't see there not being some sort of built in command to do this..



You might try 

ftp://coast.cs.purdue.edu/pub/tools/unix/sysutils/ttywatcher

You'll have to compile it yourself, but you can use it to watch what the other user is typing as he is entering commands. I don't know for sure if it will complile on  Mac, but it's worth a shot.

Here's another tty watcher type program, this will compile under FreeBSD, so it may compile on your Mac.

http://www.freebsddiary.org/watch.php


----------



## btoneill (Dec 2, 2003)

isolder said:
			
		

> The only way? for sure?



If you're not root, or trying to see the output of a terminal that you own, yeah, it's really the only way. Now, if you are root, you can basically do anything you want, just depends on how much you know about the system to figure it out, and how intrusive you want to be. As dafuser said, there are some other apps that are tty/pty watchers (a tty would be the actual terminal you're connected to, such as if you were connected to a unix box with a VT100 terminal via a serial port, a pty is a pseudo-terminal, which is what is used when you open an xterm/terminal, telnet/ssh to a box, etc.). What a tty/pty does is, it's basically a special file that anything you type into the terminal is written to the file, and anything that is displayed in the terminal the "OS" wrote to the file. If you run 'ps $$' from terminal, you should get an output similar to (this is on Solaris, so the output/naming of the tty/pty is slightly different):

```
$ ps $$
PID     TT          S  TIME COMMAND
17348 pts/31   S  0:00  bash
```

Your current shell, which in this case is bash, is running on pts/31, which is the special file /dev/pts/31. If you then open another terminal as yourself, and you run 'cat /dev/pts/31' everything that you type into the previous shell. Depending on how the system reacts (different systems are slightly different, haven't actually done this on OS X) you'll see what is typed, but the system may never actually act upon what you're typing (some strangeness can occur, it's kinda wacky). You could type "ls" and hit enter as many times as you want, but depending on timing and other things, it may or may not go thru as whichever process reads the data from the pty file first, gets it, in some cases it may be your 'cat' command, in others it may be the shell that is awaiting input. Depending on how an application is written to "snoop" what is going across a tty/pty you may be able to run it to watch another tty/pty that you own, or you may need root access to do some other "magic" to get things to go thru smoothly. Or, just do the easy thing, and use screen  What screen does is, it makes its own tty/pty that you own, and it controls access to it, So you're able to mess with who can read/write to it, and it can also handle redirection of the data from it. It's a really fun program, with thousands of uses.

Brian


----------

