]> git.ipfire.org Git - thirdparty/util-linux.git/blame - term-utils/script.1
Manual pages: use the term "exit status"
[thirdparty/util-linux.git] / term-utils / script.1
CommitLineData
6dbe3af9
KZ
1.\" Copyright (c) 1980, 1990 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)script.1 6.5 (Berkeley) 7/27/91
33.\"
543f6b6c 34.TH SCRIPT "1" "October 2019" "util-linux" "User Commands"
c5e7b9fa
SK
35.SH NAME
36script \- make typescript of terminal session
37.SH SYNOPSIS
38.B script
6e72fa59
BS
39[options]
40.RI [ file ]
c5e7b9fa
SK
41.SH DESCRIPTION
42.B script
daee4d95
KZ
43makes a typescript of everything on your terminal session. The terminal
44data are stored in raw form to the log file and information about timing
45to another (optional) structured log file. The timing log file is necessary to replay
46the session later by
47.B scriptreplay (1)
48and to store additional information about the session.
49.PP
c1c2ee0b
KZ
50Since version 2.35
51.B script
52supports multiple streams and allows to log input and output to separate
2fb684f0 53files or all the one file. This version also supports new timing file
543f6b6c 54which records additional information. The command
d51f8ec1
KZ
55.B scriptreplay \-\-summary
56then provides all the information.
57
c5e7b9fa 58.PP
6dbe3af9 59If the argument
c5e7b9fa 60.I file
ddbdb792 61or option \fB\-\-log\-out\fR \fIfile\fR is given,
c5e7b9fa 62.B script
6e72fa59 63saves the dialogue in this
c5e7b9fa 64.IR file .
6e72fa59
BS
65If no filename is given, the dialogue is saved in the file
66.BR typescript .
7d5617c4
KZ
67.PP
68Note that log input by \fB\-\-log\-in\fR or \fB\-\-log\-io\fR may be security
69sensitive operation as the log file contains all terminal session input (it
70means also passwords) independently on the terminal echo flag setting.
c5e7b9fa 71.SH OPTIONS
aefe9893
FM
72Below, the \fIsize\fR argument may be followed by the multiplicative
73suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB
eb024893 74(the "iB" is optional, e.g., "K" has the same meaning as "KiB"), or the suffixes
aefe9893 75KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
c5e7b9fa
SK
76.TP
77\fB\-a\fR, \fB\-\-append\fR
6dbe3af9 78Append the output to
c5e7b9fa 79.I file
6e72fa59
BS
80or to
81.BR typescript ,
6dbe3af9 82retaining the prior contents.
c5e7b9fa
SK
83.TP
84\fB\-c\fR, \fB\-\-command\fR \fIcommand\fR
73bc3206 85Run the
c5e7b9fa
SK
86.I command
87rather than an interactive shell. This makes it easy for a script to capture
88the output of a program that behaves differently when its stdout is not a
89tty.
90.TP
1eee1acb 91\fB\-E\fR, \fB\-\-echo\fR \fIwhen\fR
543f6b6c
SK
92This option controls the ECHO flag for pseudoterminal within the session. The
93supported modes are
94.IR always ,
95.IR never ,
96or
97.IR auto .
98The default is
99.I auto
100-- in this case, ECHO is disabled if the current standard input is a
101terminal to avoid double-echo, and enabled if standard input is not terminal
102(for example pipe:
103.BR "echo date | script" )
104to avoid missing input in the session log.
1eee1acb 105.TP
c5e7b9fa 106\fB\-e\fR, \fB\-\-return\fR
a87f49f6
MK
107Return the exit status of the child process. Uses the same format as bash
108termination on signal termination exit status is 128+n. The exit status of
6343ee8c 109the child process is always stored in type script file too.
c5e7b9fa
SK
110.TP
111\fB\-f\fR, \fB\-\-flush\fR
112Flush output after each write. This is nice for telecooperation: one person
1c4c6024 113does `mkfifo foo; script \-f foo', and another can supervise real-time what is
8e0b90e0
KZ
114being done using `cat foo'. Note that flush has an impact on performance, it's
115possible to use SIGUSR1 to flush logs on demand.
c5e7b9fa
SK
116.TP
117\fB\-\-force\fR
543f6b6c
SK
118Allow the default output file
119.B typescript
120to be a hard or symbolic link. The command will follow a symbolic link.
c5e7b9fa 121.TP
c1c2ee0b
KZ
122\fB\-B\fR, \fB\-\-log\-io\fR \fIfile\fR
123Log input and output to the same
124\fIfile\fR. Note, this option makes sense only if \fB\-\-log\-timing\fR is
125also specified, otherwise it's impossible to separate output and input streams from
126the log \fIfile\fR.
127.TP
70062aad
KZ
128\fB\-I\fR, \fB\-\-log\-in\fR \fIfile\fR
129Log input to the \fIfile\fR. The log output is disabled if only \fB\-\-log\-in\fR
130specified.
131.sp
2fb684f0 132Use this logging functionality carefully as it logs all input, including input
543f6b6c 133when terminal has disabled echo flag (for example password inputs).
70062aad 134.TP
ddbdb792 135\fB\-O\fR, \fB\-\-log\-out\fR \fIfile\fR
543f6b6c
SK
136Log output to the \fIfile\fR. The default is to log output to the file with
137name
138.B typescript
139if the option \fB\-\-log\-out\fR or \fB\-\-log\-in\fR is not given. The log
140output is disabled if only \fB\-\-log\-in\fR specified.
ddbdb792 141.TP
fc58044f 142\fB\-T\fR, \fB\-\-log\-timing\fR \fIfile\fR
543f6b6c 143Log timing information to the \fIfile\fR. Two timing file formats are supported
c1c2ee0b 144now. The classic format is used when only one stream (input or output) logging
543f6b6c 145is enabled. The multi-stream format is used on \fB\-\-log\-io\fR or when
c1c2ee0b 146\fB\-\-log\-in\fR and \fB\-\-log\-out\fR are used together.
467aa4c1 147See also \fB\-\-logging\-format\fR.
daee4d95 148.TP
467aa4c1 149\fB\-m\fR, \fB\-\-logging\-format\fR \fIformat\fR
543f6b6c
SK
150Force use
151.I advanced
152or
153.I classic
154format. The default is the classic format to log only output and the
155advanced format when input as well as output logging is requested.
fc58044f 156.sp
c1c2ee0b
KZ
157.RS
158.B Classic format
159.PP
160The log contains two fields, separated by a space. The first
fc58044f 161field indicates how much time elapsed since the previous output. The second
c1c2ee0b
KZ
162field indicates how many characters were output this time.
163.sp
daee4d95 164.B Advanced (multi-stream) format
c1c2ee0b
KZ
165.PP
166The first field is entry type itentifier ('I'nput, 'O'utput, 'H'eader, 'S'ignal).
167The socond field is how much time elapsed since the previous entry, and rest of the entry is type specific data.
168.RE
fc58044f 169.TP
aefe9893
FM
170\fB\-o\fR, \fB\-\-output-limit\fR \fIsize\fR
171Limit the size of the typescript and timing files to
172.I size
173and stop the child process after this size is exceeded. The calculated
174file size does not include the start and done messages that the
175.B script
176command prepends and appends to the child process output.
177Due to buffering, the resulting output file might be larger than the specified value.
178.TP
c5e7b9fa 179\fB\-q\fR, \fB\-\-quiet\fR
6f3c9c34 180Be quiet (do not write start and done messages to standard output).
c5e7b9fa 181.TP
3cf274c9 182\fB\-t\fR[\fIfile\fR], \fB\-\-timing\fR[=\fIfile\fR]
c5e7b9fa
SK
183Output timing data to standard error, or to
184.I file
fc58044f
KZ
185when given. This option is deprecated in favour of \fB\-\-log\-timing\fR where
186the \fIfile\fR argument is not optional.
c5e7b9fa
SK
187.TP
188\fB\-V\fR, \fB\-\-version\fR
b4362b6f 189Display version information and exit.
c5e7b9fa
SK
190.TP
191\fB\-h\fR, \fB\-\-help\fR
b4362b6f 192Display help text and exit.
c5e7b9fa 193.SH NOTES
6dbe3af9 194The script ends when the forked shell exits (a
c5e7b9fa 195.I control-D
6e72fa59 196for the Bourne shell
dbeb1d73 197.RB ( sh (1p)),
6dbe3af9 198and
c5e7b9fa
SK
199.IR exit ,
200.I logout
6dbe3af9 201or
c5e7b9fa 202.I control-d
6dbe3af9 203(if
c5e7b9fa 204.I ignoreeof
6dbe3af9
KZ
205is not set) for the
206C-shell,
c5e7b9fa
SK
207.BR csh (1)).
208.PP
6dbe3af9 209Certain interactive commands, such as
c5e7b9fa 210.BR vi (1),
6dbe3af9 211create garbage in the typescript file.
6e72fa59 212.B script
c5e7b9fa
SK
213works best with commands that do not manipulate the screen, the results are
214meant to emulate a hardcopy terminal.
8fd4a7aa
SB
215.PP
216It is not recommended to run
217.B script
c8a550a1 218in non-interactive shells. The inner shell of
8fd4a7aa 219.B script
c8a550a1 220is always interactive, and this could lead to unexpected results. If you use
8fd4a7aa 221.B script
ab52a8bc 222in the shell initialization file, you have to avoid entering an infinite
c8a550a1
BS
223loop. You can use for example the \fB\%.profile\fR file, which is read
224by login shells only:
8fd4a7aa
SB
225.RS
226.RE
227.sp
228.na
229.RS
230.nf
1c4c6024 231if test \-t 0 ; then
8fd4a7aa 232 script
ab52a8bc 233 exit
8fd4a7aa
SB
234fi
235.fi
236.RE
c8a550a1 237.ad
8fd4a7aa 238.PP
ab52a8bc
SB
239You should also avoid use of script in command pipes, as
240.B script
241can read more input than you would expect.
242.PP
8e0b90e0
KZ
243.SH SIGNALS
244Upon receiving
2fb684f0 245.BR SIGUSR1 ,
8e0b90e0
KZ
246.B script
247immediately flushes the output files.
248.PP
c5e7b9fa 249.SH ENVIRONMENT
6dbe3af9 250The following environment variable is utilized by
c5e7b9fa
SK
251.BR script :
252.TP
253.B SHELL
6dbe3af9 254If the variable
6e72fa59 255.B SHELL
6dbe3af9 256exists, the shell forked by
c5e7b9fa 257.B script
6e72fa59
BS
258will be that shell. If
259.B SHELL
c5e7b9fa
SK
260is not set, the Bourne shell is assumed. (Most shells set this variable
261automatically).
262.SH SEE ALSO
263.BR csh (1)
6dbe3af9 264(for the
c5e7b9fa 265.I history
ffc43748 266mechanism),
cb4631fc
KZ
267.BR scriptreplay (1),
268.BR scriptlive (1),
c5e7b9fa 269.SH HISTORY
6dbe3af9 270The
c5e7b9fa
SK
271.B script
272command appeared in 3.0BSD.
273.SH BUGS
6e72fa59 274.B script
6dbe3af9 275places
6e72fa59 276.I everything
c5e7b9fa
SK
277in the log file, including linefeeds and backspaces. This is not what the
278naive user expects.
63ddc7ba
KZ
279.PP
280.B script
c8a550a1
BS
281is primarily designed for interactive terminal sessions. When stdin
282is not a terminal (for example: \fBecho foo | script\fR), then the session
283can hang, because the interactive shell within the script session misses EOF and
63ddc7ba 284.B script
c8a550a1 285has no clue when to close the session. See the \fBNOTES\fR section for more information.
c5e7b9fa 286.SH AVAILABILITY
601d12fb 287The script command is part of the util-linux package and is available from
d673b74e 288.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
c5e7b9fa
SK
289Linux Kernel Archive
290.UE .