How To Replay The Recorded Terminal Sessions Using Scriptreplay Command
A while ago, we have learned how to record everything you do in Terminal using Script command on Linux. Using Script command, we can record the Terminal sessions in a typescript file and view them later using Cat command or any other text viewing applications. Today, we are going to see how replay the recorded Terminal sessions using Scriptreplay command on Linux.
The Scriptreplay is used to replay a typescript created by the “Script” command to the standard output. It is part of the util-linux package on RPM-based systems and bsdutils package on DEB-based systems and it comes pre-installed on most modern Linux operating systems. So, we don’t need to install it.
Replay Recorded Terminal Sessions Using Scriptreplay
As you may already know, the cat command will only the display typescript, but won’t play them. If you want to replay the Terminal activity instead of just viewing it, use “scriptreplay” command.
To replay the terminal activities using scriptreplay, you must first record it using “script” command with timing information in a file using -t parameter like below.
$ script -a my_terminal_activities -t=time.log
$ script -a my_terminal_activities --timing=time.log
- terminal.log is the the file that contains timing output of the typescript. You can use any name of your choice, for example time.txt, timing.log etc.
- my_terminal_activities is the file that contains the output script’s terminal output i.e. all recorded terminal activities.
Now, do whatever you want to do in your Terminal. For example, I am going to run some random Linux commands in my Terminal.
$ lsb_release -a
$ uname -a
After running all commands, end the recording with command:
After done with the recording, simply replay it with command:
$ scriptreplay -t=time.log my_terminal_activities
$ scriptreplay --timing=time.log my_terminal_activities
This command will start to replay the recorded terminal session instead of just showing the whole activity.
Here is a sample output from my Ubuntu 18.04 system:
Increase or decrease playback speed
By default, Scriptreplay will replay the output at the same speed as the way it originally appeared when the typescript was recorded. You can, however, increase or decrease the playback speed as you please.
For example, to replay the typescript at double(i.e. 2x speed) the original speed, run:
$ scriptreplay -t=terminal.log my_terminal_activities 2
To replay a typescript at half the original speed:
$ scriptreplay -t=terminal.log my_terminal_activities 0.5
To replay script with ten times slower than the original speed, run:
$ scriptreplay -t=terminal.log my_terminal_activities 0.1
Please note that Scriptreplay simply displays the session activity recorded with Script command. It will not actually run the commands/programs that were run when the typescript was recorded. Since the same information is simply being displayed, scriptreplay is only guaranteed to work properly if run on the same type of terminal the typescript was recorded on.
For help, run:
$ scriptreplay --help Usage: scriptreplay [-t] timingfile [typescript] [divisor] Play back terminal typescripts, using timing information. Options: -t, --timing <file> script timing output file -s, --typescript <file> script terminal session output file -d, --divisor <num> speed up or slow down execution with time divisor -m, --maxdelay <num> wait at most this many seconds between updates -h, --help display this help -V, --version display version
More details can be found in the man pages.
$ man scriptreplay
- Asciinema – Record Terminal Sessions And Share Them On The Web
- How To Save Commands And Use Them On Demand
- Bookmark The Linux Commands For Easier Repeated Invocation
- Apply Tags To Linux Commands To Easily Retrieve Them From History
- Easily Recall Forgotten Linux Commands Using Apropos
- Pet – A Simple Command-line Snippet Manager