Home > Package & System Management > scriptreplay

scriptreplay: Replaying Terminal Sessions

scriptreplay is a tool that replays terminal sessions (typescript) recorded by the 'script' command, along with timing information. It recreates everything a user typed and outputted in the terminal at the recorded time intervals, making it useful for various purposes such as education, demonstrations, troubleshooting, and security audits. It is particularly effective for reproducing complex command sequences or specific scenarios.

Overview

scriptreplay replays a session using two files generated by the 'script' command: a typescript file containing the terminal output and a timing file recording the time intervals for each output. This allows for a visually accurate reproduction of what happened in the actual terminal.

Key Features

  • Accurate replay of recorded terminal sessions
  • Realistic reproduction based on timing information
  • Provides playback speed control
  • Useful for education, demonstrations, and troubleshooting

Required Files

scriptreplay requires the following two files, which are generated by the 'script' command.

  • typescript file: File containing all terminal output (default: 'typescript')
  • timing file: File containing time interval information between outputs (created with 'script -t' option)

Key Options

The scriptreplay command offers several options to control the session playback.

File Specification and Playback Control

Generated command:

Try combining the commands.

Description:

`scriptreplay` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Demonstrates various ways to replay recorded terminal sessions using scriptreplay.

Basic Session Recording and Replay

# Start session recording (creates timing.log and typescript.log files)
script -t timing.log -a typescript.log
# Enter commands and perform actions here.
ls -l
pwd
exit

# Replay the recorded session
scriptreplay -t timing.log -s typescript.log

First, record a session using the 'script' command, then replay it with 'scriptreplay'.

Replay Session at 2x Speed

scriptreplay -d 2 -t timing.log -s typescript.log

Replays the recorded session at twice the normal speed.

Replay Session at 0.5x Speed (Slow)

scriptreplay -d 0.5 -t timing.log -s typescript.log

Replays the recorded session at half the normal speed.

Replay with Default Filenames

# Record with default filenames using script command
script -t
# ... perform actions ...
exit

# Replay with default filenames
scriptreplay

If the script command recorded with default filenames (typescript, timing), replay without specifying filenames.

Tips & Precautions

Tips and precautions for effectively using scriptreplay.

Integration with script Command

scriptreplay must be used with files generated by the 'script' command. It is particularly important to use the 'script -t' option to record timing information.

  • Always use the format `script -t <timing_file> -a <typescript_file>` when recording sessions.
  • If using default filenames (`typescript`, `timing`), `script -t` is sufficient.

File Management

Recorded session files (typescript, timing) are plain text files and may contain sensitive information. After replaying, it is advisable to securely delete the files or restrict their access permissions as needed.

Playback Environment

scriptreplay reproduces the terminal environment exactly as it was. Therefore, the output layout may appear differently depending on the current terminal's size or settings during playback. For the best viewing experience, it is recommended to play back in a terminal environment similar to the one used during recording.


Same category commands