]> git.ipfire.org Git - thirdparty/util-linux.git/blame_incremental - term-utils/script.1
script: add option --log-timing
[thirdparty/util-linux.git] / term-utils / script.1
... / ...
CommitLineData
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.\"
34.TH SCRIPT "1" "June 2014" "util-linux" "User Commands"
35.SH NAME
36script \- make typescript of terminal session
37.SH SYNOPSIS
38.B script
39[options]
40.RI [ file ]
41.SH DESCRIPTION
42.B script
43makes a typescript of everything displayed on your terminal. It is useful for
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
48If the argument
49.I file
50or option \fB\-\-log\-out\fR \fIfile\fR is given,
51.B script
52saves the dialogue in this
53.IR file .
54If no filename is given, the dialogue is saved in the file
55.BR typescript .
56.SH OPTIONS
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.
61.TP
62\fB\-a\fR, \fB\-\-append\fR
63Append the output to
64.I file
65or to
66.BR typescript ,
67retaining the prior contents.
68.TP
69\fB\-c\fR, \fB\-\-command\fR \fIcommand\fR
70Run the
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
77Return the exit code of the child process. Uses the same format as bash
78termination on signal termination exit code is 128+n. The exit code of
79the child process is always stored in type script file too.
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
90\fB\-O\fR, \fB\-\-log\-out\fR \fIfile\fR
91Log output to the \fIfile\fR. The default is to log the file with name 'typescript'
92if the option is not given.
93.TP
94\fB\-T\fR, \fB\-\-log\-timing\fR \fIfile\fR
95Log timing information to the \fIfile\fR.
96.sp
97This log data contains two fields, separated by a space. The first
98field indicates how much time elapsed since the previous output. The second
99field indicates how many characters were output this time. This information
100can be used to replay typescripts with realistic typing and output delays.
101.TP
102\fB\-o\fR, \fB\-\-output-limit\fR \fIsize\fR
103Limit the size of the typescript and timing files to
104.I size
105and stop the child process after this size is exceeded. The calculated
106file size does not include the start and done messages that the
107.B script
108command prepends and appends to the child process output.
109Due to buffering, the resulting output file might be larger than the specified value.
110.TP
111\fB\-q\fR, \fB\-\-quiet\fR
112Be quiet (do not write start and done messages to standard output).
113.TP
114\fB\-t\fR[\fIfile\fR], \fB\-\-timing\fR[=\fIfile\fR]
115Output timing data to standard error, or to
116.I file
117when given. This option is deprecated in favour of \fB\-\-log\-timing\fR where
118the \fIfile\fR argument is not optional.
119.TP
120\fB\-V\fR, \fB\-\-version\fR
121Display version information and exit.
122.TP
123\fB\-h\fR, \fB\-\-help\fR
124Display help text and exit.
125.SH NOTES
126The script ends when the forked shell exits (a
127.I control-D
128for the Bourne shell
129.RB ( sh (1p)),
130and
131.IR exit ,
132.I logout
133or
134.I control-d
135(if
136.I ignoreeof
137is not set) for the
138C-shell,
139.BR csh (1)).
140.PP
141Certain interactive commands, such as
142.BR vi (1),
143create garbage in the typescript file.
144.B script
145works best with commands that do not manipulate the screen, the results are
146meant to emulate a hardcopy terminal.
147.PP
148It is not recommended to run
149.B script
150in non-interactive shells. The inner shell of
151.B script
152is always interactive, and this could lead to unexpected results. If you use
153.B script
154in the shell initialization file, you have to avoid entering an infinite
155loop. You can use for example the \fB\%.profile\fR file, which is read
156by login shells only:
157.RS
158.RE
159.sp
160.na
161.RS
162.nf
163if test -t 0 ; then
164 script
165 exit
166fi
167.fi
168.RE
169.ad
170.PP
171You should also avoid use of script in command pipes, as
172.B script
173can read more input than you would expect.
174.PP
175.SH ENVIRONMENT
176The following environment variable is utilized by
177.BR script :
178.TP
179.B SHELL
180If the variable
181.B SHELL
182exists, the shell forked by
183.B script
184will be that shell. If
185.B SHELL
186is not set, the Bourne shell is assumed. (Most shells set this variable
187automatically).
188.SH SEE ALSO
189.BR csh (1)
190(for the
191.I history
192mechanism),
193.BR scriptreplay (1)
194.SH HISTORY
195The
196.B script
197command appeared in 3.0BSD.
198.SH BUGS
199.B script
200places
201.I everything
202in the log file, including linefeeds and backspaces. This is not what the
203naive user expects.
204.PP
205.B script
206is primarily designed for interactive terminal sessions. When stdin
207is not a terminal (for example: \fBecho foo | script\fR), then the session
208can hang, because the interactive shell within the script session misses EOF and
209.B script
210has no clue when to close the session. See the \fBNOTES\fR section for more information.
211.SH AVAILABILITY
212The script command is part of the util-linux package and is available from
213.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
214Linux Kernel Archive
215.UE .