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 a 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.
-c, --command command
-E, --echo when
The default is auto — in this case, ECHO enabled for the pseudoterminal slave; if the current standard input is a terminal, ECHO is disabled for it to prevent double echo; if the current standard input is not a terminal (for example pipe: echo date | script) then keeping ECHO enabled for the pseudoterminal slave enables the standard input data to be viewed on screen while being recorded to session log simultaneously.
Note that 'never' mode affects content of the session output log, because users input is not repeated on output.
-B, --log-io file
-I, --log-in file
Use this logging functionality carefully as it logs all input, including input when terminal has disabled echo flag (for example, password inputs).
-O, --log-out file
-T, --log-timing file
-m, --logging-format format
Advanced (multi-stream) format
-o, --output-limit size
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
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.
For bug reports, use the issue tracker at <https://github.com/util-linux/util-linux/issues>.
The script command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.