xref: /netbsd-src/usr.bin/script/script.1 (revision eaea20be3fc0bee6acb49bea73b8728ab885b74d)
1.\"	$NetBSD: script.1,v 1.14 2022/01/16 19:04:00 christos Exp $
2.\"
3.\" Copyright (c) 1980, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	@(#)script.1	8.1 (Berkeley) 6/6/93
31.\"
32.Dd January 16, 2022
33.Dt SCRIPT 1
34.Os
35.Sh NAME
36.Nm script
37.Nd make typescript of terminal session
38.Sh SYNOPSIS
39.Nm
40.Op Fl adefpqr
41.Op Fl c Ar command
42.Op Ar file
43.Sh DESCRIPTION
44.Nm
45makes a typescript of everything printed on your terminal.
46It is useful for students who need a hardcopy record of an interactive
47session as proof of an assignment, as the typescript file
48can be printed out later with
49.Xr lpr 1 .
50.Pp
51If the argument
52.Ar file
53is given,
54.Nm
55saves all dialogue in
56.Ar file .
57If no file name is given, the typescript is saved in the file
58.Pa typescript  .
59.Pp
60Option:
61.Bl -tag -width Ds
62.It Fl a
63Append the output to
64.Ar file
65or
66.Pa typescript ,
67retaining the prior contents.
68.It Fl c Ar command
69Run the named
70.Ar command
71instead of the shell.
72Useful for capturing the output of a program that behaves differently when
73associated with a tty.
74.It Fl d
75When playing back a session with the
76.Fl p
77flag, don't sleep between records when playing back a timestamped session.
78.It Fl e
79Exit with the shell-style exit status of the shell or
80.Ar command ,
81instead of always exiting successfully.
82.It Fl f
83Flush output after each write.
84This is useful for watching the script output in real time.
85.It Fl p
86Play back a session recorded with the
87.Fl r
88flag in real time.
89.It Fl q
90Be quiet, and don't output started and ended lines.
91.It Fl r
92Record a session with input, output, and timestamping.
93.El
94.Pp
95The script ends when the forked shell exits (a
96.Em control-D
97to exit
98the Bourne shell
99.Pf ( Xr sh 1 ) ,
100and
101.Em exit ,
102.Em logout
103or
104.Em control-d
105(if
106.Em ignoreeof
107is not set) for the
108C-shell,
109.Xr csh 1 ) .
110.Pp
111Certain interactive commands, such as
112.Xr vi 1 ,
113create garbage in the typescript file.
114.Nm
115works best with commands that do not manipulate the
116screen, the results are meant to emulate a hardcopy
117terminal.
118.Sh ENVIRONMENT
119The following environment variable is used by
120.Nm :
121.Bl -tag -width SHELL
122.It Ev SHELL
123If the variable
124.Ev SHELL
125exists, the shell forked by
126.Nm
127will be that shell.
128If
129.Ev SHELL
130is not set, the Bourne shell
131is assumed.
132(Most shells set this variable automatically).
133.El
134.Sh SEE ALSO
135.Xr csh 1
136(for the
137.Em history
138mechanism).
139.Sh HISTORY
140The
141.Nm
142command appeared in
143.Bx 3.0 .
144.Sh BUGS
145.Nm
146places
147.Sy everything
148in the log file, including linefeeds and backspaces.
149This is not what the naive user expects.
150