1SCRIPT(1)                        User Commands                       SCRIPT(1)
2
3
4

NAME

6       script - make typescript of terminal session
7

SYNOPSIS

9       script [options] [file]
10

DESCRIPTION

12       script  makes a typescript of everything on your terminal session.  The
13       terminal data are stored in raw form to the log  file  and  information
14       about timing to another (optional) structured log file.  The timing log
15       file is necessary to replay the session later by scriptreplay  (1)  and
16       to store additional information about the session.
17
18       Since  version  2.35 script supports multiple streams and allows to log
19       input and output to separate files or all the one file.   This  version
20       also  supports  new  timing  file which records additional information.
21       The command scriptreplay --summary then provides all the information.
22
23
24       If the argument file or option --log-out file is  given,  script  saves
25       the  dialogue  in  this file.  If no filename is given, the dialogue is
26       saved in the file typescript.
27
28       Note that log input by --log-in or --log-io may be  security  sensitive
29       operation as the log file contains all terminal session input (it means
30       also passwords) independently on the terminal echo flag setting.
31

OPTIONS

33       Below, the size argument may be followed by the multiplicative suffixes
34       KiB  (=1024),  MiB  (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB
35       and YiB (the "iB" is optional,  e.g.,  "K"  has  the  same  meaning  as
36       "KiB"),  or the suffixes KB (=1000), MB (=1000*1000), and so on for GB,
37       TB, PB, EB, ZB and YB.
38
39       -a, --append
40              Append the output to file or to typescript, retaining the  prior
41              contents.
42
43       -c, --command command
44              Run the command rather than an interactive shell.  This makes it
45              easy for a script to  capture  the  output  of  a  program  that
46              behaves differently when its stdout is not a tty.
47
48       -E, --echo when
49              This option controls the ECHO flag for pseudoterminal within the
50              session.  The supported modes are always, never, or  auto.   The
51              default is auto -- in this case, ECHO is disabled if the current
52              standard input is a terminal to avoid double-echo,  and  enabled
53              if standard input is not terminal (for example pipe: echo date |
54              script) to avoid missing input in the session log.
55
56       -e, --return
57              Return the exit code of the child process.  Uses the same format
58              as  bash  termination  on signal termination exit code is 128+n.
59              The exit code of the child process  is  always  stored  in  type
60              script file too.
61
62       -f, --flush
63              Flush  output  after  each write.  This is nice for telecoopera‐
64              tion: one person does `mkfifo foo; script -f foo',  and  another
65              can  supervise  real-time  what  is  being done using `cat foo'.
66              Note that flush has an impact on performance, it's  possible  to
67              use SIGUSR1 to flush logs on demand.
68
69       --force
70              Allow  the  default  output file typescript to be a hard or sym‐
71              bolic link.  The command will follow a symbolic link.
72
73       -B, --log-io file
74              Log input and output to the same file.  Note, this option  makes
75              sense  only  if  --log-timing  is also specified, otherwise it's
76              impossible to separate output and input  streams  from  the  log
77              file.
78
79       -I, --log-in file
80              Log  input  to  the  file.   The  log output is disabled if only
81              --log-in specified.
82
83              Use this logging functionality carefully as it logs  all  input,
84              including  input when terminal has disabled echo flag (for exam‐
85              ple password inputs).
86
87       -O, --log-out file
88              Log output to the file.  The default is to  log  output  to  the
89              file with name typescript if the option --log-out or --log-in is
90              not given.  The log output is disabled if only  --log-in  speci‐
91              fied.
92
93       -T, --log-timing file
94              Log timing information to the file.  Two timing file formats are
95              supported now.  The classic format is used when only one  stream
96              (input  or  output) logging is enabled.  The multi-stream format
97              is used on --log-io or when  --log-in  and  --log-out  are  used
98              together.  See also --logging-format.
99
100       -m, --logging-format format
101              Force  use advanced or classic format.  The default is the clas‐
102              sic format to log only output and the advanced format when input
103              as well as output logging is requested.
104
105              Classic format
106
107              The  log  contains  two fields, separated by a space.  The first
108              field indicates how much time elapsed since the previous output.
109              The  second field indicates how many characters were output this
110              time.
111
112              Advanced (multi-stream) format
113
114              The first field is entry  type  itentifier  ('I'nput,  'O'utput,
115              'H'eader,  'S'ignal).  The socond field is how much time elapsed
116              since the previous entry, and rest of the entry is type specific
117              data.
118
119       -o, --output-limit size
120              Limit  the  size  of the typescript and timing files to size and
121              stop the child process after this size is exceeded.  The  calcu‐
122              lated  file  size  does  not include the start and done messages
123              that the script  command  prepends  and  appends  to  the  child
124              process  output.   Due  to  buffering, the resulting output file
125              might be larger than the specified value.
126
127       -q, --quiet
128              Be quiet (do not write start and done messages to standard  out‐
129              put).
130
131       -t[file], --timing[=file]
132              Output  timing  data  to  standard error, or to file when given.
133              This option is deprecated in favour of  --log-timing  where  the
134              file argument is not optional.
135
136       -V, --version
137              Display version information and exit.
138
139       -h, --help
140              Display help text and exit.
141

NOTES

143       The script ends when the forked shell exits (a control-D for the Bourne
144       shell (sh(1p)), and exit, logout or control-d (if ignoreeof is not set)
145       for the C-shell, csh(1)).
146
147       Certain  interactive  commands,  such  as  vi(1), create garbage in the
148       typescript file.  script works best with commands that do  not  manipu‐
149       late the screen, the results are meant to emulate a hardcopy terminal.
150
151       It  is  not  recommended  to run script in non-interactive shells.  The
152       inner shell of script is always interactive, and  this  could  lead  to
153       unexpected  results.   If  you  use  script in the shell initialization
154       file, you have to avoid entering an infinite loop.   You  can  use  for
155       example the .profile file, which is read by login shells only:
156
157              if test -t 0 ; then
158                  script
159                  exit
160              fi
161
162       You  should  also  avoid  use of script in command pipes, as script can
163       read more input than you would expect.
164

SIGNALS

166       Upon receiving SIGUSR1, script immediately flushes the output files.
167

ENVIRONMENT

169       The following environment variable is utilized by script:
170
171       SHELL  If the variable SHELL exists, the shell forked by script will be
172              that  shell.   If SHELL is not set, the Bourne shell is assumed.
173              (Most shells set this variable automatically).
174

SEE ALSO

176       csh(1) (for the history mechanism), scriptreplay(1), scriptlive(1),
177

HISTORY

179       The script command appeared in 3.0BSD.
180

BUGS

182       script places everything in  the  log  file,  including  linefeeds  and
183       backspaces.  This is not what the naive user expects.
184
185       script  is  primarily designed for interactive terminal sessions.  When
186       stdin is not a terminal (for example: echo foo | script), then the ses‐
187       sion  can hang, because the interactive shell within the script session
188       misses EOF and script has no clue when to close the session.   See  the
189       NOTES section for more information.
190

AVAILABILITY

192       The  script  command is part of the util-linux package and is available
193       from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-
194       linux/⟩.
195
196
197
198util-linux                       October 2019                        SCRIPT(1)
Impressum