Monday, August 25, 2008

Sharing a Session

You can use script and mkfifo to allow a second session to supervise the first using this very simple hack.

# on 1st terminal
mkfifo /tmp/session
script -f /tmp/session

# on 2nd terminal
cat /tmp/session

Now the 2nd terminal can interactively watch whatever is going on with the 1st terminal. Occasionally some control characters will get a little garbled when a lot of curses activity is going on, but in general, it works pretty well.


Unknown said...

Awesome, thanks! I used to do it with gnu/screen but this is easier to set up :)

foo said...

Nice use of script. As above commenter mentioned, you can get similar functionality from screen with:

# terminal 1
$ screen


# terminal 2
$ screen -x

This also allows distributed pair programming, since both users can be RW on the screen session. For RO setup, your script trick is probably much easier.


Unknown said...

Zachary, things get a little more complicated when terminal 2 is operated by another user logged in in the same machine.