Linux "script" Command Line Options and Examples
make typescript of terminal session

script makes a typescript of everything displayed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves the dialogue in this file.


Usage:

script [options] [file]




Command Line Options:

-a
Append the output to file or to typescript, retaining the prior contents.
script -a ...
-c
Run the command rather than an interactive shell. This makes it easy for a script to capture the out‐put of a program that behaves differently when its stdout is not a tty.
script -c ...
-e
Return the exit code of the child process. Uses the same format as bash termination on signal termina‐tion exit code is 128+n.
script -e ...
-f
Flush output after each write. This is nice for telecooperation: one person does `mkfifo foo; script
script -f ...
--force
Allow the default output destination, i.e. the typescript file, to be a hard or symbolic link. Thecommand will follow a symbolic link.
script --force ...
-q
Be quiet (do not write start and done messages to standard output).
script -q ...
-t[file]
Output timing data to standard error, or to file when given. This data contains two fields, separatedby a space. The first field indicates how much time elapsed since the previous output. The secondfield indicates how many characters were output this time. This information can be used to replaytypescripts with realistic typing and output delays.
script -t[file] ...
-V
Display version information and exit.
script -V ...
-h
Display help text and exit.NOTESThe script ends when the forked shell exits (a control-D for the Bourne shell (sh(1)), and exit, logout orcontrol-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 withcommands 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 interac‐tive, and this could lead to unexpected results. If you use script in the shell initialization file, you haveto avoid entering an infinite loop. You can use for example the .profile file, which is read by login shellsonly:if test -t 0 ; thenscriptexitfiYou should also avoid use of script in command pipes, as script can read more input than you would expect.ENVIRONMENTThe following environment variable is utilized by script:SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, theBourne shell is assumed. (Most shells set this variable automatically).
script -h ...