SCRIPT(1) | User Commands | SCRIPT(1) |
script - make typescript of terminal session
script [options] [file]
script makes a typescript of everything on your terminal session. The terminal data are stored in raw form to the log file and information about timing to another (optional) structured log file. The timing log file is necessary to replay the session later by scriptreplay(1) and to store additional information about the session.
Since version 2.35, script supports multiple streams and allows the logging of input and output to separate files or all the one file. This version also supports new timing file which records additional information. The command scriptreplay --summary then provides all the information.
If the argument file or option --log-out file is given, script saves the dialogue in this file. If no filename is given, the dialogue is saved in the file typescript.
Note that logging input using --log-in or --log-io may record security-sensitive information as the log file contains all terminal session input (e.g., passwords) independently of the terminal echo flag setting.
Below, the size argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB"), or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
Use this logging functionality carefully as it logs all input, including input when terminal has disabled echo flag (for example, password inputs).
The log contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time.
Advanced (multi-stream) format
The first field is an entry type identifier ('I'nput, 'O'utput, 'H'eader, 'S'ignal). The socond field is how much time elapsed since the previous entry, and the rest of the entry is type-specific data.
Upon receiving SIGUSR1, script immediately flushes the output files.
The following environment variable is utilized by script:
The script ends when the forked shell exits (a control-D for the Bourne shell (sh(1p)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)).
Certain interactive commands, such as vi(1), create garbage in the typescript file. script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal.
It is not recommended to run script in non-interactive shells. The inner shell of script is always interactive, and this could lead to unexpected results. If you use script in the shell initialization file, you have to avoid entering an infinite loop. You can use for example the .profile file, which is read by login shells only:
if test -t 0 ; then
script
exit fi
You should also avoid use of script in command pipes, as script can read more input than you would expect.
The script command appeared in 3.0BSD.
script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.
script is primarily designed for interactive terminal sessions. When stdin is not a terminal (for example: echo foo | script), then the session can hang, because the interactive shell within the script session misses EOF and script has no clue when to close the session. See the NOTES section for more information.
csh(1) (for the history mechanism), scriptreplay(1), scriptlive(1),
The script command is part of the util-linux package and is available from Linux Kernel Archive.
October 2019 | util-linux |