isolder said:
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):
Code:
$ 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