2006-12-06 17:25:32 -06:00
|
|
|
.\" Copyright (c) 1980, 1990 Regents of the University of California.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)script.1 6.5 (Berkeley) 7/27/91
|
|
|
|
.\"
|
2019-12-11 13:36:26 -06:00
|
|
|
.TH SCRIPT "1" "October 2019" "util-linux" "User Commands"
|
2011-09-17 16:12:17 -05:00
|
|
|
.SH NAME
|
|
|
|
script \- make typescript of terminal session
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B script
|
2014-07-15 16:07:37 -05:00
|
|
|
[options]
|
|
|
|
.RI [ file ]
|
2011-09-17 16:12:17 -05:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.B script
|
2019-06-19 08:47:44 -05:00
|
|
|
makes a typescript of everything on your terminal session. The terminal
|
|
|
|
data are stored in raw form to the log file and information about timing
|
|
|
|
to another (optional) structured log file. The timing log file is necessary to replay
|
|
|
|
the session later by
|
2020-07-15 03:15:44 -05:00
|
|
|
.BR scriptreplay (1)
|
2019-06-19 08:47:44 -05:00
|
|
|
and to store additional information about the session.
|
|
|
|
.PP
|
2020-07-15 03:15:44 -05:00
|
|
|
Since version 2.35,
|
2019-04-12 09:27:54 -05:00
|
|
|
.B script
|
2020-07-14 04:57:41 -05:00
|
|
|
supports multiple streams and allows the logging of input and output to separate
|
2019-12-13 18:14:40 -06:00
|
|
|
files or all the one file. This version also supports new timing file
|
2019-12-11 13:36:26 -06:00
|
|
|
which records additional information. The command
|
2019-10-02 07:22:12 -05:00
|
|
|
.B scriptreplay \-\-summary
|
|
|
|
then provides all the information.
|
|
|
|
|
2011-09-17 16:12:17 -05:00
|
|
|
.PP
|
2006-12-06 17:25:32 -06:00
|
|
|
If the argument
|
2011-09-17 16:12:17 -05:00
|
|
|
.I file
|
2019-04-12 05:13:08 -05:00
|
|
|
or option \fB\-\-log\-out\fR \fIfile\fR is given,
|
2011-09-17 16:12:17 -05:00
|
|
|
.B script
|
2014-07-15 16:07:37 -05:00
|
|
|
saves the dialogue in this
|
2011-09-17 16:12:17 -05:00
|
|
|
.IR file .
|
2014-07-15 16:07:37 -05:00
|
|
|
If no filename is given, the dialogue is saved in the file
|
2020-07-15 03:15:44 -05:00
|
|
|
.IR typescript .
|
2019-06-19 06:05:46 -05:00
|
|
|
.PP
|
2020-07-15 03:15:44 -05:00
|
|
|
Note that logging input using \fB\-\-log\-in\fR or \fB\-\-log\-io\fR
|
|
|
|
may record security-sensitive information
|
|
|
|
as the log file contains all terminal session input
|
|
|
|
(e.g., passwords)
|
|
|
|
independently of the terminal echo flag setting.
|
2011-09-17 16:12:17 -05:00
|
|
|
.SH OPTIONS
|
2018-05-14 04:20:06 -05:00
|
|
|
Below, the \fIsize\fR argument may be followed by the multiplicative
|
|
|
|
suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB
|
2019-12-14 16:42:47 -06:00
|
|
|
(the "iB" is optional, e.g., "K" has the same meaning as "KiB"), or the suffixes
|
2018-05-14 04:20:06 -05:00
|
|
|
KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
|
|
|
\fB\-a\fR, \fB\-\-append\fR
|
2006-12-06 17:25:32 -06:00
|
|
|
Append the output to
|
2011-09-17 16:12:17 -05:00
|
|
|
.I file
|
2014-07-15 16:07:37 -05:00
|
|
|
or to
|
2020-07-15 03:15:44 -05:00
|
|
|
.IR typescript ,
|
2006-12-06 17:25:32 -06:00
|
|
|
retaining the prior contents.
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
|
|
|
\fB\-c\fR, \fB\-\-command\fR \fIcommand\fR
|
2011-08-10 15:37:31 -05:00
|
|
|
Run the
|
2011-09-17 16:12:17 -05:00
|
|
|
.I command
|
|
|
|
rather than an interactive shell. This makes it easy for a script to capture
|
|
|
|
the output of a program that behaves differently when its stdout is not a
|
|
|
|
tty.
|
|
|
|
.TP
|
2019-11-25 05:39:52 -06:00
|
|
|
\fB\-E\fR, \fB\-\-echo\fR \fIwhen\fR
|
2020-08-27 04:50:25 -05:00
|
|
|
This option controls the ECHO flag for the slave end of the session's pseudoterminal.
|
2020-07-15 03:15:44 -05:00
|
|
|
The supported modes are
|
2019-12-11 13:36:26 -06:00
|
|
|
.IR always ,
|
|
|
|
.IR never ,
|
|
|
|
or
|
|
|
|
.IR auto .
|
2020-08-27 04:50:25 -05:00
|
|
|
.sp
|
2019-12-11 13:36:26 -06:00
|
|
|
The default is
|
|
|
|
.I auto
|
2020-08-27 04:50:25 -05:00
|
|
|
-- in this case, ECHO enabled for the pseudoterminal slave; if
|
|
|
|
the current standard input is a terminal, ECHO is disabled for it
|
|
|
|
to prevent double echo; if the current standard input is not a terminal
|
2019-12-11 13:36:26 -06:00
|
|
|
(for example pipe:
|
|
|
|
.BR "echo date | script" )
|
2020-08-27 04:50:25 -05:00
|
|
|
then keeping ECHO enabled for the pseudoterminal slave enables the standard
|
|
|
|
input data to be viewed on screen while being recorded to session log
|
|
|
|
simultaneously.
|
|
|
|
.sp
|
|
|
|
Note that 'never' mode affects content of the session output log, because
|
|
|
|
users input is not repeated on output.
|
2019-11-25 05:39:52 -06:00
|
|
|
.TP
|
2011-09-17 16:12:17 -05:00
|
|
|
\fB\-e\fR, \fB\-\-return\fR
|
2020-05-19 07:54:07 -05:00
|
|
|
Return the exit status of the child process. Uses the same format as bash
|
2020-07-15 03:15:44 -05:00
|
|
|
termination on signal termination
|
|
|
|
(i.e., exit status is 128 + the signal number). The exit status of
|
|
|
|
the child process is always stored in the type script file too.
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
|
|
|
\fB\-f\fR, \fB\-\-flush\fR
|
|
|
|
Flush output after each write. This is nice for telecooperation: one person
|
2020-07-15 03:15:44 -05:00
|
|
|
does `mkfifo foo; script \-f foo',
|
|
|
|
and another can supervise in real-time what is
|
|
|
|
being done using `cat foo'. Note that flush has an impact on performance; it's
|
2019-12-09 09:10:02 -06:00
|
|
|
possible to use SIGUSR1 to flush logs on demand.
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
|
|
|
\fB\-\-force\fR
|
2019-12-11 13:36:26 -06:00
|
|
|
Allow the default output file
|
2020-07-15 03:15:44 -05:00
|
|
|
.I typescript
|
2019-12-11 13:36:26 -06:00
|
|
|
to be a hard or symbolic link. The command will follow a symbolic link.
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
2019-04-12 09:27:54 -05:00
|
|
|
\fB\-B\fR, \fB\-\-log\-io\fR \fIfile\fR
|
|
|
|
Log input and output to the same
|
|
|
|
\fIfile\fR. Note, this option makes sense only if \fB\-\-log\-timing\fR is
|
|
|
|
also specified, otherwise it's impossible to separate output and input streams from
|
|
|
|
the log \fIfile\fR.
|
|
|
|
.TP
|
2019-04-12 07:14:55 -05:00
|
|
|
\fB\-I\fR, \fB\-\-log\-in\fR \fIfile\fR
|
|
|
|
Log input to the \fIfile\fR. The log output is disabled if only \fB\-\-log\-in\fR
|
|
|
|
specified.
|
|
|
|
.sp
|
2019-12-13 18:14:40 -06:00
|
|
|
Use this logging functionality carefully as it logs all input, including input
|
2020-07-15 03:15:44 -05:00
|
|
|
when terminal has disabled echo flag (for example, password inputs).
|
2019-04-12 07:14:55 -05:00
|
|
|
.TP
|
2019-04-12 05:13:08 -05:00
|
|
|
\fB\-O\fR, \fB\-\-log\-out\fR \fIfile\fR
|
2019-12-11 13:36:26 -06:00
|
|
|
Log output to the \fIfile\fR. The default is to log output to the file with
|
|
|
|
name
|
2020-07-15 03:15:44 -05:00
|
|
|
.I typescript
|
2019-12-11 13:36:26 -06:00
|
|
|
if the option \fB\-\-log\-out\fR or \fB\-\-log\-in\fR is not given. The log
|
|
|
|
output is disabled if only \fB\-\-log\-in\fR specified.
|
2019-04-12 05:13:08 -05:00
|
|
|
.TP
|
2019-04-12 05:47:03 -05:00
|
|
|
\fB\-T\fR, \fB\-\-log\-timing\fR \fIfile\fR
|
2019-12-11 13:36:26 -06:00
|
|
|
Log timing information to the \fIfile\fR. Two timing file formats are supported
|
2019-04-12 09:27:54 -05:00
|
|
|
now. The classic format is used when only one stream (input or output) logging
|
2019-12-11 13:36:26 -06:00
|
|
|
is enabled. The multi-stream format is used on \fB\-\-log\-io\fR or when
|
2019-04-12 09:27:54 -05:00
|
|
|
\fB\-\-log\-in\fR and \fB\-\-log\-out\fR are used together.
|
2019-10-02 07:05:01 -05:00
|
|
|
See also \fB\-\-logging\-format\fR.
|
2019-06-19 08:47:44 -05:00
|
|
|
.TP
|
2019-10-02 07:05:01 -05:00
|
|
|
\fB\-m\fR, \fB\-\-logging\-format\fR \fIformat\fR
|
2020-07-15 03:15:44 -05:00
|
|
|
Force use of
|
2019-12-11 13:36:26 -06:00
|
|
|
.I advanced
|
|
|
|
or
|
|
|
|
.I classic
|
|
|
|
format. The default is the classic format to log only output and the
|
|
|
|
advanced format when input as well as output logging is requested.
|
2019-04-12 05:47:03 -05:00
|
|
|
.sp
|
2019-04-12 09:27:54 -05:00
|
|
|
.RS
|
|
|
|
.B Classic format
|
|
|
|
.PP
|
|
|
|
The log contains two fields, separated by a space. The first
|
2019-04-12 05:47:03 -05:00
|
|
|
field indicates how much time elapsed since the previous output. The second
|
2019-04-12 09:27:54 -05:00
|
|
|
field indicates how many characters were output this time.
|
|
|
|
.sp
|
2019-06-19 08:47:44 -05:00
|
|
|
.B Advanced (multi-stream) format
|
2019-04-12 09:27:54 -05:00
|
|
|
.PP
|
2020-07-15 03:15:44 -05:00
|
|
|
The first field is an entry type identifier
|
|
|
|
('I'nput, 'O'utput, 'H'eader, 'S'ignal).
|
|
|
|
The socond field is how much time elapsed since the previous entry,
|
|
|
|
and the rest of the entry is type-specific data.
|
2019-04-12 09:27:54 -05:00
|
|
|
.RE
|
2019-04-12 05:47:03 -05:00
|
|
|
.TP
|
2018-05-14 04:20:06 -05:00
|
|
|
\fB\-o\fR, \fB\-\-output-limit\fR \fIsize\fR
|
|
|
|
Limit the size of the typescript and timing files to
|
|
|
|
.I size
|
|
|
|
and stop the child process after this size is exceeded. The calculated
|
|
|
|
file size does not include the start and done messages that the
|
|
|
|
.B script
|
|
|
|
command prepends and appends to the child process output.
|
|
|
|
Due to buffering, the resulting output file might be larger than the specified value.
|
|
|
|
.TP
|
2011-09-17 16:12:17 -05:00
|
|
|
\fB\-q\fR, \fB\-\-quiet\fR
|
2017-04-18 05:12:44 -05:00
|
|
|
Be quiet (do not write start and done messages to standard output).
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
2017-07-18 07:29:07 -05:00
|
|
|
\fB\-t\fR[\fIfile\fR], \fB\-\-timing\fR[=\fIfile\fR]
|
2011-09-17 16:12:17 -05:00
|
|
|
Output timing data to standard error, or to
|
|
|
|
.I file
|
2019-04-12 05:47:03 -05:00
|
|
|
when given. This option is deprecated in favour of \fB\-\-log\-timing\fR where
|
|
|
|
the \fIfile\fR argument is not optional.
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
|
|
|
\fB\-V\fR, \fB\-\-version\fR
|
2013-10-14 14:34:39 -05:00
|
|
|
Display version information and exit.
|
2011-09-17 16:12:17 -05:00
|
|
|
.TP
|
|
|
|
\fB\-h\fR, \fB\-\-help\fR
|
2013-10-14 14:34:39 -05:00
|
|
|
Display help text and exit.
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
.SH SIGNALS
|
|
|
|
Upon receiving
|
|
|
|
.BR SIGUSR1 ,
|
|
|
|
.B script
|
|
|
|
immediately flushes the output files.
|
|
|
|
.SH ENVIRONMENT
|
|
|
|
The following environment variable is utilized by
|
|
|
|
.BR script :
|
|
|
|
.TP
|
|
|
|
.B SHELL
|
|
|
|
If the variable
|
|
|
|
.B SHELL
|
|
|
|
exists, the shell forked by
|
|
|
|
.B script
|
|
|
|
will be that shell. If
|
|
|
|
.B SHELL
|
|
|
|
is not set, the Bourne shell is assumed. (Most shells set this variable
|
|
|
|
automatically).
|
2011-09-17 16:12:17 -05:00
|
|
|
.SH NOTES
|
2006-12-06 17:25:32 -06:00
|
|
|
The script ends when the forked shell exits (a
|
2011-09-17 16:12:17 -05:00
|
|
|
.I control-D
|
2014-07-15 16:07:37 -05:00
|
|
|
for the Bourne shell
|
2019-08-24 16:34:16 -05:00
|
|
|
.RB ( sh (1p)),
|
2006-12-06 17:25:32 -06:00
|
|
|
and
|
2011-09-17 16:12:17 -05:00
|
|
|
.IR exit ,
|
|
|
|
.I logout
|
2006-12-06 17:25:32 -06:00
|
|
|
or
|
2011-09-17 16:12:17 -05:00
|
|
|
.I control-d
|
2006-12-06 17:25:32 -06:00
|
|
|
(if
|
2011-09-17 16:12:17 -05:00
|
|
|
.I ignoreeof
|
2006-12-06 17:25:32 -06:00
|
|
|
is not set) for the
|
|
|
|
C-shell,
|
2011-09-17 16:12:17 -05:00
|
|
|
.BR csh (1)).
|
|
|
|
.PP
|
2006-12-06 17:25:32 -06:00
|
|
|
Certain interactive commands, such as
|
2011-09-17 16:12:17 -05:00
|
|
|
.BR vi (1),
|
2006-12-06 17:25:32 -06:00
|
|
|
create garbage in the typescript file.
|
2014-07-15 16:07:37 -05:00
|
|
|
.B script
|
2011-09-17 16:12:17 -05:00
|
|
|
works best with commands that do not manipulate the screen, the results are
|
|
|
|
meant to emulate a hardcopy terminal.
|
2015-02-11 08:07:52 -06:00
|
|
|
.PP
|
|
|
|
It is not recommended to run
|
|
|
|
.B script
|
2016-03-17 04:39:12 -05:00
|
|
|
in non-interactive shells. The inner shell of
|
2015-02-11 08:07:52 -06:00
|
|
|
.B script
|
2016-03-17 04:39:12 -05:00
|
|
|
is always interactive, and this could lead to unexpected results. If you use
|
2015-02-11 08:07:52 -06:00
|
|
|
.B script
|
2015-02-13 12:59:22 -06:00
|
|
|
in the shell initialization file, you have to avoid entering an infinite
|
2016-03-17 04:39:12 -05:00
|
|
|
loop. You can use for example the \fB\%.profile\fR file, which is read
|
|
|
|
by login shells only:
|
2015-02-11 08:07:52 -06:00
|
|
|
.sp
|
|
|
|
.na
|
|
|
|
.RS
|
|
|
|
.nf
|
2019-12-15 18:51:57 -06:00
|
|
|
if test \-t 0 ; then
|
2015-02-11 08:07:52 -06:00
|
|
|
script
|
2015-02-13 12:59:22 -06:00
|
|
|
exit
|
2015-02-11 08:07:52 -06:00
|
|
|
fi
|
|
|
|
.fi
|
|
|
|
.RE
|
2016-03-17 04:39:12 -05:00
|
|
|
.ad
|
2015-02-11 08:07:52 -06:00
|
|
|
.PP
|
2020-07-15 03:15:44 -05:00
|
|
|
You should also avoid use of
|
|
|
|
.B script
|
|
|
|
in command pipes, as
|
2015-02-13 12:59:22 -06:00
|
|
|
.B script
|
|
|
|
can read more input than you would expect.
|
2011-09-17 16:12:17 -05:00
|
|
|
.SH HISTORY
|
2006-12-06 17:25:32 -06:00
|
|
|
The
|
2011-09-17 16:12:17 -05:00
|
|
|
.B script
|
|
|
|
command appeared in 3.0BSD.
|
|
|
|
.SH BUGS
|
2014-07-15 16:07:37 -05:00
|
|
|
.B script
|
2006-12-06 17:25:32 -06:00
|
|
|
places
|
2014-07-15 16:07:37 -05:00
|
|
|
.I everything
|
2011-09-17 16:12:17 -05:00
|
|
|
in the log file, including linefeeds and backspaces. This is not what the
|
|
|
|
naive user expects.
|
2015-06-25 04:55:42 -05:00
|
|
|
.PP
|
|
|
|
.B script
|
2016-03-17 04:39:12 -05:00
|
|
|
is primarily designed for interactive terminal sessions. When stdin
|
|
|
|
is not a terminal (for example: \fBecho foo | script\fR), then the session
|
|
|
|
can hang, because the interactive shell within the script session misses EOF and
|
2015-06-25 04:55:42 -05:00
|
|
|
.B script
|
2016-03-17 04:39:12 -05:00
|
|
|
has no clue when to close the session. See the \fBNOTES\fR section for more information.
|
2020-05-21 02:28:21 -05:00
|
|
|
.SH SEE ALSO
|
|
|
|
.BR csh (1)
|
|
|
|
(for the
|
|
|
|
.I history
|
|
|
|
mechanism),
|
|
|
|
.BR scriptreplay (1),
|
|
|
|
.BR scriptlive (1),
|
2011-09-17 16:12:17 -05:00
|
|
|
.SH AVAILABILITY
|
2010-11-30 04:41:59 -06:00
|
|
|
The script command is part of the util-linux package and is available from
|
2016-12-17 02:06:57 -06:00
|
|
|
.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
|
2011-09-17 16:12:17 -05:00
|
|
|
Linux Kernel Archive
|
|
|
|
.UE .
|