Archive for the 'utilities' Category

TermRecord: Terminal Screencast in a Self-Contained HTML File


Some time ago I wrote a few posts ( 1, 2 ) on how to use script to record a terminal session and then scriptreplay to play it back. This functionality can be very useful by enabling you the power to show others what happens when you do insert anything here.

I have been happy with this solution for a while until one day Wolfgang Richter commented on my original post and shared a project he has been working on known as TermRecord.

I gave it a spin and have been using it quite a bit. Sharing a terminal recording now becomes much easier as you can simply email the .html file or you can host it yourself and share links. As long the people you are sharing with have a browser then they can watch the playback. Thus, it is not tied to a system with a particular piece of software and clicking a link to view is very easy to do :)

Basics of TermRecord

Before anything else we need to install TermRecord. Currently TermRecord is available in the python package index (hopefully will be packaged in some major distributions soon) and can be installed using pip.
[root@localhost ~]# pip install TermRecord Downloading/unpacking TermRecord Downloading TermRecord-1.1.3.tar.gz (49kB): 49kB downloaded Running egg_info for package TermRecord ... ... Successfully installed TermRecord Jinja2 markupsafe Cleaning up...
Now you can make a self-contained html file for sharing in a couple of ways.

First, you can use TermRecord to convert already existing timing and log files that were created using the script command by specifying them as inputs to TermRecord:
[root@localhost ~]# TermRecord -o screencast.html -t screencast.timing -s screencast.log

The other option is to create a new recording using TermRecord like so:
[root@localhost ~]# TermRecord -o screencast.html Script started, file is /tmp/tmp5I4SYq [root@localhost ~]# [root@localhost ~]# #This is a screencast. [root@localhost ~]# exit exit Script done, file is /tmp/tmp5I4SYq

And.. Done. Now you can email or share the html file any way you like. If you would like to see some examples of terminal recordings you can check out the TermRecord github page or here is one from my previous post on wordpress/docker.


Terminal Screencast Revisit: Log output from a multiplexed terminal

Traditionally with script you have really only been able to log the output of a simple "single session" terminal window. However, if you capture the timing data from script you can actually log much more than that.

In a previous post I talked about how to save the timing data using script and then play it back using scriptreplay. If you use this technique and also use a a terminal multiplexer such as screen or tmux you can capture much more information in your screencast.

To see an example of this you can watch the video below where I use scriptreplay to play back an earlier recorded screencast.

Additionally, you can download the screencast.timing and screencast.log if you like.

Cheers, Dusty Mabe

Create a screencast of a terminal session using scriptreplay.

I recently ran into an issue where I needed to demo a project without actually being present for the demo. I thought about recording (into some video format) a screencast of my terminal window and then having my audience play it at the time of the demo. This would have worked just fine, but, as I was browsing the internet searching for exactly how to record a screencast of this nature, I ran across a blog post talking about how to play back terminal sessions using the output of the script program. This piqued my interest for several reasons:
  1. I have used script many times to log results of tests.
  2. This method of recording a shell session is much more efficient than recording it into video because it only stores the actual text of the output as well as some timing information.

In order to "record" using script you store the terminal output and the timing information to two different files using a command like the following:

script -t 2> screencast.timing screencast.log

The -t in the command causes script to output timing data to standard error. The 2> screencast.timing causes standard error to be redirected to the file screencast.timing. The screencast.log file will hold everything printed on the terminal during the course of the screencast session.

After running the command, execute a few programs (ls, echo "Hi Planet", etc...) and then type exit to end the session.

Now the screencast is stored in the two files. You can play back the screencast using:

scriptreplay screencast.timing screencast.log

And Voila. As long as your target audience has a box with script/scriptreplay installed then they can view your screencast!

I have included a screencast.timing and a screencast.log file you can download and use with scriptreplay if you would like to demo this out. The files combined are under 5K in size for a 1 minute 40 second screencast, however I think the actual size of the files depends more on how much data was output rather than the length of the screencast.

Even better than using my screencast, create one yourself!