]>
Commit | Line | Data |
---|---|---|
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 |
36 | script \- 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 |
43 | makes a typescript of everything on your terminal session. The terminal |
44 | data are stored in raw form to the log file and information about timing | |
45 | to another (optional) structured log file. The timing log file is necessary to replay | |
46 | the session later by | |
47 | .B scriptreplay (1) | |
48 | and to store additional information about the session. | |
49 | .PP | |
c1c2ee0b KZ |
50 | Since version 2.35 |
51 | .B script | |
52 | supports multiple streams and allows to log input and output to separate | |
d51f8ec1 KZ |
53 | files or all the one file. This version also supports new timing file |
54 | which records additional information. The command | |
55 | .B scriptreplay \-\-summary | |
56 | then provides all the information. | |
57 | ||
c5e7b9fa | 58 | .PP |
6dbe3af9 | 59 | If the argument |
c5e7b9fa | 60 | .I file |
ddbdb792 | 61 | or option \fB\-\-log\-out\fR \fIfile\fR is given, |
c5e7b9fa | 62 | .B script |
6e72fa59 | 63 | saves the dialogue in this |
c5e7b9fa | 64 | .IR file . |
6e72fa59 BS |
65 | If no filename is given, the dialogue is saved in the file |
66 | .BR typescript . | |
7d5617c4 KZ |
67 | .PP |
68 | Note that log input by \fB\-\-log\-in\fR or \fB\-\-log\-io\fR may be security | |
69 | sensitive operation as the log file contains all terminal session input (it | |
70 | means also passwords) independently on the terminal echo flag setting. | |
c5e7b9fa | 71 | .SH OPTIONS |
aefe9893 FM |
72 | Below, the \fIsize\fR argument may be followed by the multiplicative |
73 | suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB | |
74 | (the "iB" is optional, e.g. "K" has the same meaning as "KiB"), or the suffixes | |
75 | KB (=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 | 78 | Append the output to |
c5e7b9fa | 79 | .I file |
6e72fa59 BS |
80 | or to |
81 | .BR typescript , | |
6dbe3af9 | 82 | retaining the prior contents. |
c5e7b9fa SK |
83 | .TP |
84 | \fB\-c\fR, \fB\-\-command\fR \fIcommand\fR | |
73bc3206 | 85 | Run the |
c5e7b9fa SK |
86 | .I command |
87 | rather than an interactive shell. This makes it easy for a script to capture | |
88 | the output of a program that behaves differently when its stdout is not a | |
89 | tty. | |
90 | .TP | |
91 | \fB\-e\fR, \fB\-\-return\fR | |
73bc3206 | 92 | Return the exit code of the child process. Uses the same format as bash |
6343ee8c KZ |
93 | termination on signal termination exit code is 128+n. The exit code of |
94 | the child process is always stored in type script file too. | |
c5e7b9fa SK |
95 | .TP |
96 | \fB\-f\fR, \fB\-\-flush\fR | |
97 | Flush output after each write. This is nice for telecooperation: one person | |
98 | does `mkfifo foo; script -f foo', and another can supervise real-time what is | |
99 | being done using `cat foo'. | |
100 | .TP | |
101 | \fB\-\-force\fR | |
102 | Allow the default output destination, i.e. the typescript file, to be a hard | |
103 | or symbolic link. The command will follow a symbolic link. | |
104 | .TP | |
c1c2ee0b KZ |
105 | \fB\-B\fR, \fB\-\-log\-io\fR \fIfile\fR |
106 | Log input and output to the same | |
107 | \fIfile\fR. Note, this option makes sense only if \fB\-\-log\-timing\fR is | |
108 | also specified, otherwise it's impossible to separate output and input streams from | |
109 | the log \fIfile\fR. | |
110 | .TP | |
70062aad KZ |
111 | \fB\-I\fR, \fB\-\-log\-in\fR \fIfile\fR |
112 | Log input to the \fIfile\fR. The log output is disabled if only \fB\-\-log\-in\fR | |
113 | specified. | |
114 | .sp | |
115 | Use this logging functionality carefully as it logs all input, including input | |
116 | when terminal has disabled echo flag (for example it log passwords in the input). | |
117 | .TP | |
ddbdb792 | 118 | \fB\-O\fR, \fB\-\-log\-out\fR \fIfile\fR |
70062aad KZ |
119 | Log output to the \fIfile\fR. The default is to log output to the file with |
120 | name 'typescript' if the option \fB\-\-log\-out\fR or \fB\-\-log\-in\fR is not | |
121 | given. The log output is disabled if only \fB\-\-log\-in\fR specified. | |
ddbdb792 | 122 | .TP |
fc58044f | 123 | \fB\-T\fR, \fB\-\-log\-timing\fR \fIfile\fR |
c1c2ee0b KZ |
124 | Log timing information to the \fIfile\fR. Two timing file formats are supporte |
125 | now. The classic format is used when only one stream (input or output) logging | |
126 | is enabled. The multi-stream format is used on \fB\-\-log\-io\fR or when | |
127 | \fB\-\-log\-in\fR and \fB\-\-log\-out\fR are used together. | |
467aa4c1 | 128 | See also \fB\-\-logging\-format\fR. |
daee4d95 | 129 | .TP |
467aa4c1 | 130 | \fB\-m\fR, \fB\-\-logging\-format\fR \fIformat\fR |
daee4d95 KZ |
131 | Force use 'advanced' or 'classic' format. The default is the classic format to |
132 | log only output and the advanced format when input as well as output logging is | |
133 | requested. | |
fc58044f | 134 | .sp |
c1c2ee0b KZ |
135 | .RS |
136 | .B Classic format | |
137 | .PP | |
138 | The log contains two fields, separated by a space. The first | |
fc58044f | 139 | field indicates how much time elapsed since the previous output. The second |
c1c2ee0b KZ |
140 | field indicates how many characters were output this time. |
141 | .sp | |
daee4d95 | 142 | .B Advanced (multi-stream) format |
c1c2ee0b KZ |
143 | .PP |
144 | The first field is entry type itentifier ('I'nput, 'O'utput, 'H'eader, 'S'ignal). | |
145 | The socond field is how much time elapsed since the previous entry, and rest of the entry is type specific data. | |
146 | .RE | |
fc58044f | 147 | .TP |
aefe9893 FM |
148 | \fB\-o\fR, \fB\-\-output-limit\fR \fIsize\fR |
149 | Limit the size of the typescript and timing files to | |
150 | .I size | |
151 | and stop the child process after this size is exceeded. The calculated | |
152 | file size does not include the start and done messages that the | |
153 | .B script | |
154 | command prepends and appends to the child process output. | |
155 | Due to buffering, the resulting output file might be larger than the specified value. | |
156 | .TP | |
c5e7b9fa | 157 | \fB\-q\fR, \fB\-\-quiet\fR |
6f3c9c34 | 158 | Be quiet (do not write start and done messages to standard output). |
c5e7b9fa | 159 | .TP |
3cf274c9 | 160 | \fB\-t\fR[\fIfile\fR], \fB\-\-timing\fR[=\fIfile\fR] |
c5e7b9fa SK |
161 | Output timing data to standard error, or to |
162 | .I file | |
fc58044f KZ |
163 | when given. This option is deprecated in favour of \fB\-\-log\-timing\fR where |
164 | the \fIfile\fR argument is not optional. | |
c5e7b9fa SK |
165 | .TP |
166 | \fB\-V\fR, \fB\-\-version\fR | |
b4362b6f | 167 | Display version information and exit. |
c5e7b9fa SK |
168 | .TP |
169 | \fB\-h\fR, \fB\-\-help\fR | |
b4362b6f | 170 | Display help text and exit. |
c5e7b9fa | 171 | .SH NOTES |
6dbe3af9 | 172 | The script ends when the forked shell exits (a |
c5e7b9fa | 173 | .I control-D |
6e72fa59 | 174 | for the Bourne shell |
dbeb1d73 | 175 | .RB ( sh (1p)), |
6dbe3af9 | 176 | and |
c5e7b9fa SK |
177 | .IR exit , |
178 | .I logout | |
6dbe3af9 | 179 | or |
c5e7b9fa | 180 | .I control-d |
6dbe3af9 | 181 | (if |
c5e7b9fa | 182 | .I ignoreeof |
6dbe3af9 KZ |
183 | is not set) for the |
184 | C-shell, | |
c5e7b9fa SK |
185 | .BR csh (1)). |
186 | .PP | |
6dbe3af9 | 187 | Certain interactive commands, such as |
c5e7b9fa | 188 | .BR vi (1), |
6dbe3af9 | 189 | create garbage in the typescript file. |
6e72fa59 | 190 | .B script |
c5e7b9fa SK |
191 | works best with commands that do not manipulate the screen, the results are |
192 | meant to emulate a hardcopy terminal. | |
8fd4a7aa SB |
193 | .PP |
194 | It is not recommended to run | |
195 | .B script | |
c8a550a1 | 196 | in non-interactive shells. The inner shell of |
8fd4a7aa | 197 | .B script |
c8a550a1 | 198 | is always interactive, and this could lead to unexpected results. If you use |
8fd4a7aa | 199 | .B script |
ab52a8bc | 200 | in the shell initialization file, you have to avoid entering an infinite |
c8a550a1 BS |
201 | loop. You can use for example the \fB\%.profile\fR file, which is read |
202 | by login shells only: | |
8fd4a7aa SB |
203 | .RS |
204 | .RE | |
205 | .sp | |
206 | .na | |
207 | .RS | |
208 | .nf | |
209 | if test -t 0 ; then | |
210 | script | |
ab52a8bc | 211 | exit |
8fd4a7aa SB |
212 | fi |
213 | .fi | |
214 | .RE | |
c8a550a1 | 215 | .ad |
8fd4a7aa | 216 | .PP |
ab52a8bc SB |
217 | You should also avoid use of script in command pipes, as |
218 | .B script | |
219 | can read more input than you would expect. | |
220 | .PP | |
c5e7b9fa | 221 | .SH ENVIRONMENT |
6dbe3af9 | 222 | The following environment variable is utilized by |
c5e7b9fa SK |
223 | .BR script : |
224 | .TP | |
225 | .B SHELL | |
6dbe3af9 | 226 | If the variable |
6e72fa59 | 227 | .B SHELL |
6dbe3af9 | 228 | exists, the shell forked by |
c5e7b9fa | 229 | .B script |
6e72fa59 BS |
230 | will be that shell. If |
231 | .B SHELL | |
c5e7b9fa SK |
232 | is not set, the Bourne shell is assumed. (Most shells set this variable |
233 | automatically). | |
234 | .SH SEE ALSO | |
235 | .BR csh (1) | |
6dbe3af9 | 236 | (for the |
c5e7b9fa | 237 | .I history |
ffc43748 | 238 | mechanism), |
f053ff1e | 239 | .BR scriptreplay (1) |
c5e7b9fa | 240 | .SH HISTORY |
6dbe3af9 | 241 | The |
c5e7b9fa SK |
242 | .B script |
243 | command appeared in 3.0BSD. | |
244 | .SH BUGS | |
6e72fa59 | 245 | .B script |
6dbe3af9 | 246 | places |
6e72fa59 | 247 | .I everything |
c5e7b9fa SK |
248 | in the log file, including linefeeds and backspaces. This is not what the |
249 | naive user expects. | |
63ddc7ba KZ |
250 | .PP |
251 | .B script | |
c8a550a1 BS |
252 | is primarily designed for interactive terminal sessions. When stdin |
253 | is not a terminal (for example: \fBecho foo | script\fR), then the session | |
254 | can hang, because the interactive shell within the script session misses EOF and | |
63ddc7ba | 255 | .B script |
c8a550a1 | 256 | has no clue when to close the session. See the \fBNOTES\fR section for more information. |
c5e7b9fa | 257 | .SH AVAILABILITY |
601d12fb | 258 | The script command is part of the util-linux package and is available from |
d673b74e | 259 | .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/ |
c5e7b9fa SK |
260 | Linux Kernel Archive |
261 | .UE . |