DEV Community

rderik
rderik

Posted on

3 1

Record your terminal session using the `script`command.

I've been in the situation where I ran a script that behaved weirdly and would love to be able to "replay" what I did to figure out what went wrong. A useful command for those cases is script(1).

The script command (introduced in 1979) allows you to record a terminal session to a file. You can later check and reference that file to analyse it as you please. Or maybe record your terminal as a demo.

As with any other Unix command, the power comes from your creativity on how to use it. You can use script to:

  • Record a demo.
  • Capture output.
  • Record session to report a bug.

You can try it just by typing script in your terminal. It opens up a new shell that will be recorded. By default, the session is saved in a file named typescript.

$ script
% ls
% exit
Enter fullscreen mode Exit fullscreen mode

You can then view the capture by using cat(1):

$ cat typescript
Enter fullscreen mode Exit fullscreen mode

If you are interested in more detail, here are my notes on how to use it:

https://rderik.com/notes/using-the-script-command-to-record-a-terminal-session/

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (2)

Collapse
 
lbonanomi profile image
lbonanomi

I really dig script. Ever want to push scriptfiles to github?

Collapse
 
rderik profile image
rderik

That's an interesting use of Gists, thanks for sharing!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay