(IFS=; sed 's/^[]0;[^^G]*^G/^M/g' <SessionLog> | while read -n 1 ITEM; do [ "$ITEM" = "^M" ] && ITEM=$'\n'; echo -ne "$ITEM"; sleep 0.05; done; echo)

Play back shell session recorded using the

This command will play back each keystroke in a session log recorded using the script command. You'll need to replace the ^[ ^G and ^M characters with CTRL-[, CTRL-G and CTRL-M. To do this you need to press CTRL-V CTRL-[ or CTRL-V CTRL-G or CTRL-V CTRL-M. You can adjust the playback typing speed by modifying the sleep. If you're not bothered about seeing each keypress then you could just use: cat session.log
Sample Output
$ script session.log
Script started, file is session.log
$ pwd
/home/jon
$ exit
Script done, file is session.log


$ (IFS=; sed 's/^[]0;[^^G]*^G/^M/g' session.log | while read -n 1 ITEM; do [ "$ITEM" = "^M" ] && ITEM=$'\n'; echo -ne "$ITEM"; sleep 0.05; done; echo)
Script started on Wed 20 Jan 2010 15:56:36 GMT
$ exit
Script done on Wed 20 Jan 2010 15:56:45 GMT

0
By: jgc
2010-01-20 16:11:32

These Might Interest You

  • This shell function takes a single argument, which is used as the base name of the .wav, .timing and .session files created. To create a screencast: screencast test type and talk ... then type 'exit' or to exit the screencast. test.wav will contain the audio from your screencast. test.session will contain text and control characters needed to paint the screen test.timing will contain timing information needed to synch individual keystrokes in test.session with the audio. to play back: aplay test.wav & scriptreplay test.{timing,session} NOTE: because the shell function uses the variable "$!", and bash likes to expand '!' during history expansion, you will need to turn off bash's history before you enter the shell function. This can be achieved using the command set +H


    2
    screencast() { arecord -R 1000 -f cd -t wav $1.wav & RECPID=$!; echo "Starting screencast in new shell. Exit subshell to quit."; script -t 2> $1.timing -a $1.session; kill $RECPID; }
    bartonski · 2011-01-20 14:35:47 0
  • I wanted to play a song from the shell and get the shell back, I also dont want to store the file if it is not needed. edit, not sure if I need to mention it... killall vlc to stop it Show Sample Output


    -1
    wget http://somesite.com/somestream.pls; cvlc somestream.pls&sleep 5; rm somestream.pls*
    tomjrace · 2011-08-04 19:24:18 0
  • this will cause any commands that you have executed in the current shell session to not be written in your bash_history file upon logout


    17
    unset HISTFILE
    syssyphus · 2009-05-20 14:46:18 4
  • The command creates new session "test", executes 'date' and then start your default shell (to keep the detached session alive). Change 'date' to fit your needs. screen -r test will attach the created session.


    0
    $ screen -S test -d -m -- sh -c 'date; exec $SHELL'
    awek · 2014-02-17 08:11:45 0
  • If all three Session IDs are the same, then you've got SSL session caching running. @ http://hezmatt.org/~mpalmer/blog/general/ssl_session_caching_in_nginx.html Show Sample Output


    0
    gnutls-cli -V -r www.google.com |grep 'Session ID'
    evandrix · 2011-06-27 23:48:05 0
  • This starts a very basic X session, with just a simple xterm. You can use this xterm to launch your preferred distant session. ssh -X john@otherbox gnome-session Try also startkde or fluxbox or xfce4-session. To switch between your two X servers, use CTRL+ALT+F7 and CTRL+ALT+F8.


    3
    xinit -- :1
    flux · 2009-07-31 23:42:28 1

What Others Think

i think scriptreplay is much better.. script -t 2>timingfile ... exit scriptreplay timingfile
alperyilmaz · 434 weeks and 3 days ago
I'd agree. I've seen scriptreplay, but I don't have access to install anything on my company servers. That makes this a nice option.
jgc · 434 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: