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