terminal session recorder/player - Programming On Unix

Users browsing this thread: 1 Guest(s)
z3bra
Grey Hair Nixers
I wrote a simple shell script to record and play terminal session. It makes use of script(1) and scriptreplay(1) (should be installed on most distros).

Code:
#!/bin/sh
#
# start recording a script, and upload it in base64 to sprunge
# usage: nx-termcast [url]

nx_upload() {
    # feel free to override, if you know what you're doing
    curl -sT- http://p.iotek.org
}

nx_record() {
    script --timing=timing typescript
    # make a motherfucking tarbomb
    tar cz . | base64 | nx_upload
}

nx_replay() {
    curl -s "$*" | base64 -d | tar xz
    scriptreplay timing typescript
}

# that's to prevent the motherfucking tarbombs
cd $(mktemp -d)

# give the impression of a clean session
clear

# either record or play, your choice
test -n "$1" && nx_replay "$*" || nx_record

Save the above in a file (preferrably named "nx-termcast") and set the execution bits on it.

Now to start recording, simply run

Code:
nx-termcast


then everything you type, and everything that appears on the terminal will get recorded. Beware when using curse based applications though, as they will be drawn with the same size in the replay. For better result, try to record with a window of 80 columns and 24 lines.

To finish recording, just run "exit" or close the pseudo-terminal with ^D. This will automatically upload your script in tar.gz format to sprunge (base64 encoded), and print the URL that you can use to access it to stdout. Just copy it, and share it!

To replay a script recorded via this script, just run:

Code:
nx-termcast http://sprunge.us/bYIJ

Feel free to try to play cast in your terminal, to have an idea of how it works ;)


And now it's your turn! Share this script, so that people start sharing scripts all around the interweb!
BANGARANG, MOTHERFUCKER
jcalve
Registered
Webtm
Members
This is pretty cool.
OH NO IM BEING HACKED
Oh nevermind, its just a typescript...