1.\" $OpenBSD: script.1,v 1.19 2021/04/28 17:44:35 tb Exp $ 2.\" $NetBSD: script.1,v 1.3 1994/12/21 08:55:41 jtc Exp $ 3.\" 4.\" Copyright (c) 1980, 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)script.1 8.1 (Berkeley) 6/6/93 32.\" 33.Dd $Mdocdate: April 28 2021 $ 34.Dt SCRIPT 1 35.Os 36.Sh NAME 37.Nm script 38.Nd make typescript of terminal session 39.Sh SYNOPSIS 40.Nm script 41.Op Fl a 42.Op Fl c Ar command 43.Op Ar file 44.Sh DESCRIPTION 45.Nm 46makes a typescript of everything printed on your terminal. 47It is useful for students who need a hardcopy record of an interactive 48session as proof of an assignment, as the typescript file 49can be printed out later with 50.Xr lpr 1 . 51.Pp 52If the argument 53.Ar file 54is given, 55.Nm 56saves all dialogue in 57.Ar file . 58If no file name is given, the typescript is saved in the file 59.Pa typescript . 60.Pp 61The options are as follows: 62.Bl -tag -width Ds 63.It Fl a 64Append the output to 65.Ar file 66or 67.Pa typescript , 68retaining the prior contents. 69.It Fl c Ar command 70Run 71.Ar command 72instead of an interactive shell. 73To run a command with arguments, enclose both in quotes. 74.El 75.Pp 76The script ends when the forked program exits (an 77.Ic exit , 78.Ic logout , 79or control-D 80.Pq Ql ^D 81will exit most interactive shells). 82.Nm 83will exit with the status of 0 unless any of its child 84processes fail, in which case, 85.Nm 86will return 1. 87.Pp 88Certain interactive commands, such as 89.Xr vi 1 , 90create garbage in the typescript file. 91.Nm 92works best with commands that do not manipulate the 93screen; the results are meant to emulate a hardcopy terminal. 94.Sh ENVIRONMENT 95.Bl -tag -width SHELL 96.It Ev SHELL 97Name of the shell to be forked by 98.Nm script . 99If not set, the Bourne shell is assumed. 100(Most shells set this variable automatically.) 101.El 102.Sh EXAMPLES 103Start a virtual machine and log all console output to a file: 104.Bd -literal -offset indent 105$ script -c "vmctl start -c myvm" myvm.typescript 106.Ed 107.Sh HISTORY 108A predecessor called 109.Nm dribble 110appeared in 111.Bx 2 . 112The 113.Nm 114command first appeared in 115.Bx 3 . 116.Sh AUTHORS 117.An Mary Ann Horton . 118.Sh BUGS 119.Nm 120places 121.Em everything 122in the log file, including linefeeds and backspaces. 123This is not what the naive user expects. 124