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