]> git.ipfire.org Git - thirdparty/util-linux.git/blame - term-utils/script.1
libmount: fix comment referring to passno field
[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.\"
6e72fa59 34.TH SCRIPT "1" "June 2014" "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
6e72fa59 43makes a typescript of everything displayed on your terminal. It is useful for
c5e7b9fa
SK
44students who need a hardcopy record of an interactive session as proof of an
45assignment, as the typescript file can be printed out later with
46.BR lpr (1).
47.PP
6dbe3af9 48If the argument
c5e7b9fa 49.I file
6dbe3af9 50is given,
c5e7b9fa 51.B script
6e72fa59 52saves the dialogue in this
c5e7b9fa 53.IR file .
6e72fa59
BS
54If no filename is given, the dialogue is saved in the file
55.BR typescript .
c5e7b9fa 56.SH OPTIONS
aefe9893
FM
57Below, the \fIsize\fR argument may be followed by the multiplicative
58suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB
59(the "iB" is optional, e.g. "K" has the same meaning as "KiB"), or the suffixes
60KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
c5e7b9fa
SK
61.TP
62\fB\-a\fR, \fB\-\-append\fR
6dbe3af9 63Append the output to
c5e7b9fa 64.I file
6e72fa59
BS
65or to
66.BR typescript ,
6dbe3af9 67retaining the prior contents.
c5e7b9fa
SK
68.TP
69\fB\-c\fR, \fB\-\-command\fR \fIcommand\fR
73bc3206 70Run the
c5e7b9fa
SK
71.I command
72rather than an interactive shell. This makes it easy for a script to capture
73the output of a program that behaves differently when its stdout is not a
74tty.
75.TP
76\fB\-e\fR, \fB\-\-return\fR
73bc3206 77Return the exit code of the child process. Uses the same format as bash
6343ee8c
KZ
78termination on signal termination exit code is 128+n. The exit code of
79the child process is always stored in type script file too.
c5e7b9fa
SK
80.TP
81\fB\-f\fR, \fB\-\-flush\fR
82Flush output after each write. This is nice for telecooperation: one person
83does `mkfifo foo; script -f foo', and another can supervise real-time what is
84being done using `cat foo'.
85.TP
86\fB\-\-force\fR
87Allow the default output destination, i.e. the typescript file, to be a hard
88or symbolic link. The command will follow a symbolic link.
89.TP
aefe9893
FM
90\fB\-o\fR, \fB\-\-output-limit\fR \fIsize\fR
91Limit the size of the typescript and timing files to
92.I size
93and stop the child process after this size is exceeded. The calculated
94file size does not include the start and done messages that the
95.B script
96command prepends and appends to the child process output.
97Due to buffering, the resulting output file might be larger than the specified value.
98.TP
c5e7b9fa 99\fB\-q\fR, \fB\-\-quiet\fR
6f3c9c34 100Be quiet (do not write start and done messages to standard output).
c5e7b9fa 101.TP
3cf274c9 102\fB\-t\fR[\fIfile\fR], \fB\-\-timing\fR[=\fIfile\fR]
c5e7b9fa
SK
103Output timing data to standard error, or to
104.I file
105when given. This data contains two fields, separated by a space. The first
106field indicates how much time elapsed since the previous output. The second
107field indicates how many characters were output this time. This information
108can be used to replay typescripts with realistic typing and output delays.
109.TP
110\fB\-V\fR, \fB\-\-version\fR
b4362b6f 111Display version information and exit.
c5e7b9fa
SK
112.TP
113\fB\-h\fR, \fB\-\-help\fR
b4362b6f 114Display help text and exit.
c5e7b9fa 115.SH NOTES
6dbe3af9 116The script ends when the forked shell exits (a
c5e7b9fa 117.I control-D
6e72fa59 118for the Bourne shell
c5e7b9fa 119.RB ( sh (1)),
6dbe3af9 120and
c5e7b9fa
SK
121.IR exit ,
122.I logout
6dbe3af9 123or
c5e7b9fa 124.I control-d
6dbe3af9 125(if
c5e7b9fa 126.I ignoreeof
6dbe3af9
KZ
127is not set) for the
128C-shell,
c5e7b9fa
SK
129.BR csh (1)).
130.PP
6dbe3af9 131Certain interactive commands, such as
c5e7b9fa 132.BR vi (1),
6dbe3af9 133create garbage in the typescript file.
6e72fa59 134.B script
c5e7b9fa
SK
135works best with commands that do not manipulate the screen, the results are
136meant to emulate a hardcopy terminal.
8fd4a7aa
SB
137.PP
138It is not recommended to run
139.B script
c8a550a1 140in non-interactive shells. The inner shell of
8fd4a7aa 141.B script
c8a550a1 142is always interactive, and this could lead to unexpected results. If you use
8fd4a7aa 143.B script
ab52a8bc 144in the shell initialization file, you have to avoid entering an infinite
c8a550a1
BS
145loop. You can use for example the \fB\%.profile\fR file, which is read
146by login shells only:
8fd4a7aa
SB
147.RS
148.RE
149.sp
150.na
151.RS
152.nf
153if test -t 0 ; then
154 script
ab52a8bc 155 exit
8fd4a7aa
SB
156fi
157.fi
158.RE
c8a550a1 159.ad
8fd4a7aa 160.PP
ab52a8bc
SB
161You should also avoid use of script in command pipes, as
162.B script
163can read more input than you would expect.
164.PP
c5e7b9fa 165.SH ENVIRONMENT
6dbe3af9 166The following environment variable is utilized by
c5e7b9fa
SK
167.BR script :
168.TP
169.B SHELL
6dbe3af9 170If the variable
6e72fa59 171.B SHELL
6dbe3af9 172exists, the shell forked by
c5e7b9fa 173.B script
6e72fa59
BS
174will be that shell. If
175.B SHELL
c5e7b9fa
SK
176is not set, the Bourne shell is assumed. (Most shells set this variable
177automatically).
178.SH SEE ALSO
179.BR csh (1)
6dbe3af9 180(for the
c5e7b9fa 181.I history
ffc43748 182mechanism),
f053ff1e 183.BR scriptreplay (1)
c5e7b9fa 184.SH HISTORY
6dbe3af9 185The
c5e7b9fa
SK
186.B script
187command appeared in 3.0BSD.
188.SH BUGS
6e72fa59 189.B script
6dbe3af9 190places
6e72fa59 191.I everything
c5e7b9fa
SK
192in the log file, including linefeeds and backspaces. This is not what the
193naive user expects.
63ddc7ba
KZ
194.PP
195.B script
c8a550a1
BS
196is primarily designed for interactive terminal sessions. When stdin
197is not a terminal (for example: \fBecho foo | script\fR), then the session
198can hang, because the interactive shell within the script session misses EOF and
63ddc7ba 199.B script
c8a550a1 200has no clue when to close the session. See the \fBNOTES\fR section for more information.
c5e7b9fa 201.SH AVAILABILITY
601d12fb 202The script command is part of the util-linux package and is available from
d673b74e 203.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
c5e7b9fa
SK
204Linux Kernel Archive
205.UE .