1.\" $MirOS: src/usr.bin/script/script.1,v 1.9 2009/09/06 13:40:19 tg Exp $ 2.\" $OpenBSD: script.1,v 1.12 2005/06/16 12:22:46 jmc Exp $ 3.\" $NetBSD: script.1,v 1.3 1994/12/21 08:55:41 jtc Exp $ 4.\" 5.\" Copyright (c) 1980, 1990, 1993 6.\" The Regents of the University of California. All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)script.1 8.1 (Berkeley) 6/6/93 33.\" 34.Dd $Mdocdate: September 6 2009 $ 35.Dt SCRIPT 1 36.Os 37.Sh NAME 38.Nm script 39.Nd make typescript of terminal session 40.Sh SYNOPSIS 41.Nm script 42.Op Fl alqsU 43.Op Fl c Ar cmd 44.Op Fl L|U Ar replstr 45.Op Fl n | Ar file 46.Sh DESCRIPTION 47.Nm 48opens a pseudo-tty master and starts an interactive shell 49which is connected to the slave tty. 50If the 51.Fl n 52option is not given, it 53makes a typescript of everything printed on your terminal. 54It is useful for students who need a hardcopy record of an interactive 55session as proof of an assignment, as the typescript file 56can be printed out later with 57.Xr lpr 1 . 58It is also useful for people who log in to a 59.Mx 60box with a terminal that is not UTF-8 capable, 61or to connect to a non-UTF-8-capable box. 62.Pp 63If the argument 64.Ar file 65is given, 66.Nm 67saves all dialogue in 68.Ar file . 69If no file name is given, the typescript is saved in the file 70.Pa typescript . 71.Pp 72The options are as follows: 73.Bl -tag -width Ds 74.It Fl a 75Append the output to 76.Ar file 77or 78.Pa typescript , 79retaining the prior contents. 80.It Fl c Ar cmd 81Instead of running 82.Li ${SHELL:\-/bin/sh} Fl i , 83execute 84.Li ${SHELL:\-/bin/sh} Fl c Ar 'cmd' . 85.It Fl L Ar replstr 86Assume the terminal uses ISO-8859-1 87.Pq Do latin1 Dc 88encoding, and convert from and to UTF-8 for the pty. 89Inconvertible characters are displayed as 90.Ar replstr , 91one per column. 92.It Fl l 93Assume the terminal uses ISO-8859-1 94.Pq Do latin1 Dc 95encoding, and convert from and to UTF-8 for the pty. 96Inconvertible characters are displayed as one question mark per column. 97.It Fl n 98Do not record a typescript. 99.It Fl q 100Be quiet. 101.It Fl s 102Start a login shell. 103.It Fl U Ar replstr 104Assume the session uses ISO-8859-1 105.Pq Do latin1 Dc 106encoding, and convert from and to UTF-8 for the pty. 107Inconvertible characters are sent to the inside shell as 108.Ar replstr , 109one per column. 110.It Fl u 111Assume the session uses ISO-8859-1 112.Pq Do latin1 Dc 113encoding, and convert from and to UTF-8 for the pty. 114Inconvertible characters are sent to the inside shell as 115one question mark per column. 116.El 117.Pp 118The script ends when the forked shell exits (a control-D 119.Pq Ql ^D 120to exit 121the Bourne shell 122.Pf ( Xr sh 1 ) , 123and 124.Ic exit , 125.Ic logout , 126or control-D 127(if 128.Va ignoreeof 129is not set) for the 130C-shell, 131.Xr csh 1 ) . 132.Nm 133will exit with the status of 0 unless any of its child 134processes fail. 135In which case, 136.Nm 137will return 1. 138.Pp 139Certain interactive commands, such as 140.Xr vi 1 , 141create garbage in the typescript file. 142.Nm 143works best with commands that do not manipulate the 144screen; the results are meant to emulate a hardcopy terminal. 145.Sh ENVIRONMENT 146.Bl -tag -width SHELL 147.It Ev SHELL 148Name of the shell to be forked by 149.Nm script . 150If not set, the Bourne shell is assumed. 151(Most shells set this variable automatically.) 152.El 153.Sh EXAMPLES 154.Li $ script 155.Pp 156Records a typescript of an interactive session. 157.Pp 158.Li $ script -ln 159.Pp 160Runs a UTF-8 session inside an ISO-8859-1 hardware terminal. 161.Pa /usr/ports/misc/screen 162can do even more, but is not part of 163.Mx . 164.Pp 165.Li $ luit -encoding 'ISO 8859-1' -- ssh remote 166.Pp 167Run inside the UTF-8 session, connects to a remote system 168which uses ISO-8859-1 encoding and ISO 2022 shift sequences. 169.Pp 170.Li $ script -unc ssh remote 171.Pp 172This is the same, without luit. 173ISO-8859-1 for the inside is hard-coded. 174.Sh SEE ALSO 175.Xr luit 1 , 176.Xr screen 1 177.Sh HISTORY 178The 179.Nm 180command appeared in 181.Bx 3.0 . 182Support for recoding between latin1 and utf-8 appeared in 183.Mx 10 . 184.Sh AUTHORS 185The recoding, execute shell command code, and codeset support 186was authored by 187.An Thorsten Glaser Aq tg@mirbsd.de . 188.Sh BUGS 189.Nm 190places 191.Em everything 192in the log file, including linefeeds and backspaces. 193This is not what the naive user expects. 194.Pp 195While double-width characters are presented as two times the 196.Ar replstr , 197combining characters are hidden. 198.Xr xterm 1 199does some sort of precomposing and then displays them together 200as single character, or, as replacement if it stands \- cf.\& 201.Pa /usr/src/contrib/samples/utf-8 202\&\- alone. 203.Nm 204just doesn't display them at all. 205GNU screen has a different, also slightly broken, logic and 206has even worse width behaviour in that file, but replaces 207unicode line-drawing characters with their ACS equivalents. 208