1SCRIPT(1) User Commands SCRIPT(1)
2
3
4
6 script - make typescript of terminal session
7
9 script [options] [file]
10
12 script makes a typescript of everything on your terminal session. The
13 terminal data are stored in raw form to the log file and information
14 about timing to another (optional) structured log file. The timing log
15 file is necessary to replay the session later by scriptreplay(1) and to
16 store additional information about the session.
17
18 Since version 2.35, script supports multiple streams and allows the
19 logging of input and output to separate files or all the one file. This
20 version also supports new timing file which records additional
21 information. The command scriptreplay --summary then provides all the
22 information.
23
24 If the argument file or option --log-out file is given, script saves
25 the dialogue in this file. If no filename is given, the dialogue is
26 saved in the file typescript.
27
28 Note that logging input using --log-in or --log-io may record
29 security-sensitive information as the log file contains all terminal
30 session input (e.g., passwords) independently of the terminal echo flag
31 setting.
32
34 Below, the size argument may be followed by the multiplicative suffixes
35 KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB
36 and YiB (the "iB" is optional, e.g., "K" has the same meaning as
37 "KiB"), or the suffixes KB (=1000), MB (=1000*1000), and so on for GB,
38 TB, PB, EB, ZB and YB.
39
40 -a, --append
41 Append the output to file or to typescript, retaining the prior
42 contents.
43
44 -c, --command command
45 Run the command rather than an interactive shell. This makes it
46 easy for a script to capture the output of a program that behaves
47 differently when its stdout is not a tty.
48
49 -E, --echo when
50 This option controls the ECHO flag for the slave end of the
51 session’s pseudoterminal. The supported modes are always, never, or
52 auto.
53
54 The default is auto — in this case, ECHO enabled for the
55 pseudoterminal slave; if the current standard input is a terminal,
56 ECHO is disabled for it to prevent double echo; if the current
57 standard input is not a terminal (for example pipe: echo date |
58 script) then keeping ECHO enabled for the pseudoterminal slave
59 enables the standard input data to be viewed on screen while being
60 recorded to session log simultaneously.
61
62 Note that 'never' mode affects content of the session output log,
63 because users input is not repeated on output.
64
65 -e, --return
66 Return the exit status of the child process. Uses the same format
67 as bash termination on signal termination (i.e., exit status is 128
68 + the signal number). The exit status of the child process is
69 always stored in the type script file too.
70
71 -f, --flush
72 Flush output after each write. This is nice for telecooperation:
73 one person does mkfifo foo; script -f foo, and another can
74 supervise in real-time what is being done using cat foo. Note that
75 flush has an impact on performance; it’s possible to use SIGUSR1 to
76 flush logs on demand.
77
78 --force
79 Allow the default output file typescript to be a hard or symbolic
80 link. The command will follow a symbolic link.
81
82 -B, --log-io file
83 Log input and output to the same file. Note, this option makes
84 sense only if --log-timing is also specified, otherwise it’s
85 impossible to separate output and input streams from the log file.
86
87 -I, --log-in file
88 Log input to the file. The log output is disabled if only --log-in
89 specified.
90
91 Use this logging functionality carefully as it logs all input,
92 including input when terminal has disabled echo flag (for example,
93 password inputs).
94
95 -O, --log-out file
96 Log output to the file. The default is to log output to the file
97 with name typescript if the option --log-out or --log-in is not
98 given. The log output is disabled if only --log-in specified.
99
100 -T, --log-timing file
101 Log timing information to the file. Two timing file formats are
102 supported now. The classic format is used when only one stream
103 (input or output) logging is enabled. The multi-stream format is
104 used on --log-io or when --log-in and --log-out are used together.
105 See also --logging-format.
106
107 -m, --logging-format format
108 Force use of advanced or classic format. The default is the classic
109 format to log only output and the advanced format when input as
110 well as output logging is requested.
111
112 Classic format
113 The log contains two fields, separated by a space. The first
114 field indicates how much time elapsed since the previous
115 output. The second field indicates how many characters were
116 output this time.
117
118 Advanced (multi-stream) format
119 The first field is an entry type identifier ('I’nput, 'O’utput,
120 'H’eader, 'S’ignal). The socond field is how much time elapsed
121 since the previous entry, and the rest of the entry is
122 type-specific data.
123
124 -o, --output-limit size
125 Limit the size of the typescript and timing files to size and stop
126 the child process after this size is exceeded. The calculated file
127 size does not include the start and done messages that the script
128 command prepends and appends to the child process output. Due to
129 buffering, the resulting output file might be larger than the
130 specified value.
131
132 -q, --quiet
133 Be quiet (do not write start and done messages to standard output).
134
135 -t[file], --timing[=file]
136 Output timing data to standard error, or to file when given. This
137 option is deprecated in favour of --log-timing where the file
138 argument is not optional.
139
140 -V, --version
141 Display version information and exit.
142
143 -h, --help
144 Display help text and exit.
145
147 Upon receiving SIGUSR1, script immediately flushes the output files.
148
150 The following environment variable is utilized by script:
151
152 SHELL
153 If the variable SHELL exists, the shell forked by script will be
154 that shell. If SHELL is not set, the Bourne shell is assumed. (Most
155 shells set this variable automatically).
156
158 The script ends when the forked shell exits (a control-D for the Bourne
159 shell (sh(1p)), and exit, logout or control-d (if ignoreeof is not set)
160 for the C-shell, csh(1)).
161
162 Certain interactive commands, such as vi(1), create garbage in the
163 typescript file. script works best with commands that do not manipulate
164 the screen, the results are meant to emulate a hardcopy terminal.
165
166 It is not recommended to run script in non-interactive shells. The
167 inner shell of script is always interactive, and this could lead to
168 unexpected results. If you use script in the shell initialization file,
169 you have to avoid entering an infinite loop. You can use for example
170 the .profile file, which is read by login shells only:
171
172 if test -t 0 ; then
173 script
174 exit
175 fi
176
177 You should also avoid use of script in command pipes, as script can
178 read more input than you would expect.
179
181 The script command appeared in 3.0BSD.
182
184 script places everything in the log file, including linefeeds and
185 backspaces. This is not what the naive user expects.
186
187 script is primarily designed for interactive terminal sessions. When
188 stdin is not a terminal (for example: echo foo | script), then the
189 session can hang, because the interactive shell within the script
190 session misses EOF and script has no clue when to close the session.
191 See the NOTES section for more information.
192
194 csh(1) (for the history mechanism), scriptreplay(1), scriptlive(1)
195
197 For bug reports, use the issue tracker at
198 https://github.com/karelzak/util-linux/issues.
199
201 The script command is part of the util-linux package which can be
202 downloaded from Linux Kernel Archive
203 <https://www.kernel.org/pub/linux/utils/util-linux/>.
204
205
206
207util-linux 2.37.2 2021-06-02 SCRIPT(1)