HOME

TheInfoList



OR:

The script command is a Unix utility that records a terminal session. It dates back to the 1979 3.0
BSD The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berk ...
.


Usage

A script session is captured in file name by default; to specify a different filename follow the command with a space and the filename as such: . The recorded format of consists of plain-text timing information (for the whole session) and verbatim command output, including whatever ANSI escape code the program has printed for formatting. It uses a
pseudoterminal In some operating systems, including Unix and Linux, a pseudoterminal, pseudotty, or PTY is a pair of pseudo-device endpoints (files) which establish asynchronous, bidirectional communication ( IPC) channel (with two ports) between two or more pr ...
for this purpose, so programs act exactly as if they were on a terminal. The util-linux command offers a replay function to its script, which supports using an extra timing file for character-level information. Some online services, such as the now-defunct shelr.tv, can also show the format as a low-bandwidth alternative to video screencasts.


Problems with ''script''

One of the problems with the script command is that it only allows logging of a child process; and often there is a need to log the command in the current process without spawning a new process, such as when automation of a script is needed that can log its own output. The Unix operating systems make this possible by use of pipes and redirects. Consider the following model examples: ;Bourne shell All shells related to
Bourne shell The Bourne shell (sh) is a Shell (computing), shell Command-line interface#Command-line interpreter, command-line interpreter for computer operating systems. The Bourne shell was the default Unix shell, shell for Version 7 Unix. Unix-like syste ...
(namely: sh, bash, and ksh) allow the stdout and stderr to be attached to a named pipe and redirected to the tee command. Example LOGNAME="script" rm -f $LOGNAME.p $LOGNAME.log mknod $LOGNAME.p p tee <$LOGNAME.p $LOGNAME.log & exec >$LOGNAME.p 2>&1 The above script records to all output of the command. However, some interactive programs (such as python) do not echo their standard input when run under the resulting shell, although they do when run under the script command, again due to the detection of a terminal.


Alternatives to Script Command

The
ttyrec ttyrec is a program or its file format capable of recording the TTY output of a text-mode program together with timestamps and then replaying it. It is widely used for example in the ''NetHack'' community for storing game replays. It is simila ...
program from 2000 provides the same kind of functionality and offers several bindings. The timing is similar to util-linux. A more modern take on the concept is "asciicast"
JSON JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
, used by asciinema.


See also

* Command line interpreter * Shebang (Unix) *
Bourne shell The Bourne shell (sh) is a Shell (computing), shell Command-line interface#Command-line interpreter, command-line interpreter for computer operating systems. The Bourne shell was the default Unix shell, shell for Version 7 Unix. Unix-like syste ...
*
Bourne-Again shell Bash is a Unix shell and command language written by Brian Fox (computer programmer), Brian Fox for the GNU Project as a free software replacement for the Bourne shell. First released in 1989, it has been used as the default login shell for most ...
* C shell * Python (programming language) * Filename extension, ''Command Name Issues'' section * Perl * Scripting language * Unix shell


References

Unix software {{unix-stub