DEV Community

Alex Turner
Alex Turner

Posted on

The Linux script command.

Linux has a built in command called script. Invoking it generates a file that effectivly records everything which is subsequently typed into and/or displayed in the terminal until such time ctrl d is pressed. Doing so ends and saves the session. Play back in the terminal is as simple as invoking another command together with the path to the saved file.

script --help

Make a typescript of a terminal session.

Options:
 -a, --append                  append the output
 -c, --command <command>       run command rather than interactive shell
 -e, --return                  return exit code of the child process
 -f, --flush                   run flush after each write
     --force                   use output file even when it is a link
 -o, --output-limit <size>     terminate if output files exceed size
 -q, --quiet                   be quiet
 -t[<file>], --timing[=<file>] output timing data to stderr or to FILE
 -h, --help                    display this help
 -V, --version                 display version

Enter fullscreen mode Exit fullscreen mode

Simply entering...

$ script --t=script_log -q scriptfile
Enter fullscreen mode Exit fullscreen mode

...will invoke script and recording of the terminal session.

To play back the session it's...

scriptreplay --timing=script_log scriptfile
Enter fullscreen mode Exit fullscreen mode

More details for reference here. Could be good to include in a repo as a means to demonstrate functionality of a CLI. More typical I suppose would be to screen record a recorded demo...


URL Scraper and site map builder.

I have coded a CLI scraper and site map builder. A first for me. Enjoying the process and learning. Got to a point of mostly tweaking. Time to move on. Good enough will do. Here's the repo on GitHub.

Top comments (0)