Format
script [-aq]
[file]
Description
script makes
a typescript of everything displayed on the terminal. The typescript
is written to the file specified by the file parameter.
If no file name is given, the typescript is saved in the current working
directory with the file name typescript. If the file
exists, the default behavior is to overwrite its contents.
script is
useful for recording shell session activity for troubleshooting and
documenting purposes.
Options
- –a
- Appends the typescript to the file.
- –q
- Quiet mode. All diagnostic messages are suppressed.
Examples
To record shell session activity
in order to document the removal of files, follow these steps:
- Begin recording the shell session activity by issuing the script command:
script
- Start removing the files and then end the recording of the shell
session activity:
rm -v removeme*
exit
- After the recording ends, the contents of the typescript created
by script will be similar to the following:
Script command is started on Fri Jan 29 11:25:15 2010.
SYS1: /u/user1/mydir> rm -v removeme*
removeme1
removeme2
removeme3
SYS1: /u/user1/mydir> exit
Script command is complete on Fri Jan 29 11:25:17 2010.
Environment variables
script uses
the following environment variable:
- SHELL
- Contains the name of the shell to be forked by script.
Localization
script uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- LC_TOD
- NLSPATH
See Localization for more
information.
Usage notes
- script forks and executes a shell according
to the value of the SHELL environment variable. If the environment
variable is not set, script uses the /bin/sh shell. script ends
when the shell process exits. Use either exit or
Ctrl-D to exit the shell process.
- Because script writes everything in
the typescript to the file including backspaces and prompts, commands
that modify terminals such as vi might create
unexpected data in the typescript.
- Before and after running script, ensure
that access to the file containing the typescript is properly controlled
because the file might contain sensitive data.
- script does not support setting 3270
passthrough mode during the shell session. As a result, OEDIT, OBROWSE,
and other utilities requiring 3270 passthrough mode will fail.
- script creates a new session and controlling
terminal for the shell process. A login accounting entry is not added
to /etc/utmpx for this session and terminal.
- script cannot be run in a background
process. For example, using an & at the end of the script command
is not supported. Executing the script command
via BPXBATCH is also not supported.
- Do not access the typescript file in use by script during
the shell session, or unexpected results might occur.
Exit values
- 0
- Successful start of the script command
- 1
- Failure due to any of the following:
- Unable to access the standard output, input or error file descriptors
- An incorrect command-line option
- Unable to open, write to, or initialize the typescript file.
- Unable to open or write to the pseudoterminal
- Unable to access the controlling terminal
- Unable to allocate system resources
- 129-255
- script was interrupted by a signal.
The exit value is the signal number combined with 128. For example,
SIGTERM (signal number 15) results in an exit value of 143.
Portability
An
approved POSIX standard does not exist for script.