The Unix script command.


script is used to take a copy of everything which is output to the terminal and place it in a log file. It should be followed by the name of the file to place the log in, and the exit command should be used to stop logging and close the file.

It can be used to obtain a copy of a program run, which should be placed in your notebook and will be a required part of an assignment submission.

Everything between the script and the exit command is logged to the file. This includes the confirmation messages from script itself.
For example:

    % script hw0.scr
    Script started, file is hw0.scr

    % ls
    hw0.scr  square.scm

    % cat square.scm
    ;; your name
    ;; your id
    ;; your section # or time

    ;; square takes a number as an input parameter and
    ;; returns the square of it.

    (define (square x)
        (* x x))

    % module load soft/tcl/8.3.1

    % stk

    Welcome to the STk interpreter version 4.0.1 [SunOS-5.7-sun4]
    Copyright  1993-1999 Erick Gallesio - I3S - CNRS / ESSI 
    STk> (load "square.scm")
    STk> square
    #[closure arglist=(x) 11b158]
    STk> (square 3)
    9
    STk> (square -5)
    25
    STk> (square 0.1)
    0.01
    STk> (square 0.00000001)
    1e-16
    STk> (square 'a)

    *** Error:
    *: not a number: a
    STk> (square 1)
    1
    STk> (square (square 3))
    81
    STk> (exit)

    % exit
    Script done, file is hw0.scr


The contents of the file hw0.scr would be :

    % less hw0.scr 
    Script started on Wed Sep 06 09:34:14 2000

    % ls
    hw0.scr  square.scm

    % cat square.scm

    ;; your name
    ;; your id
    ;; your section # or time

    ;; square takes a number as an input parameter and
    ;; returns the square of it.

    (define (square x)
        (* x x))

    % module load soft/tcl

    % stk

    Welcome to the STk interpreter version 4.0.1 [SunOS-5.7-sun4]
    Copyright  1993-1999 Erick Gallesio - I3S - CNRS / ESSI 
    STk> (load "square.scm")
    STk> square
    #[closure arglist=(x) 11b158]
    STk> (square 3)
    9
    STk> (square -5)
    25
    STk> (square 0.1)
    0.01
    STk> (square 0.00000001)
    1e-16
    STk> (square 'a)

    *** Error:
    *: not a number: a
    STk> (square 1)
    1
    STk> (square (square 3))
    81
    STk> (exit)

    % exit
    script done on Wed Sep 06 09:35:20 2000


script will complain if:

script will not complain if:


On-line Manual page for 'script'


User Commands                                           script(1)



NAME
     script - make record of a terminal session

SYNOPSIS
     script [ -a ] [ filename ]

DESCRIPTION
     script makes a record of everything printed on your  screen.
     The  record  is  written  to  filename.   If no file name is
     given, the record is saved in the file 'typescript'.

     The script command forks and creates a sub-shell,  according
     to  the value of $SHELL, and records the text from this ses-
     sion.  The script ends when the forked shell exits  or  when
     CTRL-D is typed.

OPTIONS
     -a   Append the session record to filename, rather than
          overwrite it.

NOTES
     script places everything that appears on the screen in
     filename, including prompts.

ATTRIBUTES
     See attributes(5) for descriptions of the following attri-
     butes:

SunOS 5.6            Last change: 8 Feb 1994                    1


Sunny Kim (kimx0320@itlabs.umn.edu)