[The Path to Root - SysAdmin Blog (Beta)] Logging a Terminal Session in Linux...

0 views
Skip to first unread message

treehead

unread,
Sep 6, 2007, 8:44:12 PM9/6/07
to tree...@googlegroups.com
[http://www.hermann-uwe.de/blog/capturing-and-replaying-console-terminal-sessions-with-script-and-scriptreplay]

Ever wonder how you can capture the output of your terminal session to a file for reference later? Check it out:

2007-02-10 17:25 — Uwe Hermann

Have you ever wondered how you can easily capture a console session on Linux (and probably most other Unix-like OSes) without the need for special video recording software?

Here's how: you can use the script(1) command (part of the bsdutils package).

  • Start the script command. Without parameters the sessions will be logged to a file called typescript. You can also supply a filename on the command line: script mysession.log.
  • Type whatever you want to record...
  • End the recording session with exit or CTRL-d.
  • You can now view the file with less -r mysession.log (it contains line feeds, escape sequences etc., so a simple text viewer will probably display garbage). You can even print it with lpr(1). Or simply display it on the terminal with cat mysession.log.

An even cooler feature is that you can replay a script with the correct timing information:

  • First you have to also record the timing information using the -t switch: script -t 2>mysession.timing mysession.log.
  • You can then replay the script: scriptreplay mysession.timing mysession.log.

See the script(1) and scriptreplay(1) manpages for more details.

—Uwe Hermann

Now you know! Thanks Uwe!



--
Posted By treehead to The Path to Root - SysAdmin Blog (Beta) at 9/06/2007 08:22:00 PM
Reply all
Reply to author
Forward
0 new messages