Operating System Information --> Unix Information --> Unix Utilities --> Printing Or Capturing The Output Of A Program In UNIX -->

Printing Or Capturing The Output Of A Program In UNIX

To capture screen output to a file use the script command. This command starts a special shell whose screen input and output is redirected to both the screen and a file. If not specified, the filename created is "typescript"; if you wish, you can specify any filename you wish:

  script  script_file

Run the commands to produce the desired output; the script runs using the Bourne (sh) shell. Never use a full screen editor while in a script shell. The resulting script file will be garbage. Backspaces and other cursor movements may also result in a less than perfect script file. In the case of backspace, you usually just get both characters at the same location or a few ^h sequences on the output depending on the printer software.

Exit the shell using the exit command. This step cannot be stressed enough! After you exit the script shell, your output should be in a file called "typescript" (or your specified alternative) that you can send to a printer.

One common problem is that users forget to exit the script shell. Usually they don't realize this until they try to logout and get a "not in login shell" message. If this happens the best thing to do is to exit each shell (type exit) until you get back to the login shell. Never try to kill the script shell you are in. See the entry on Not in login shell for more information.

How are we doing? Comments on this page?
Office of Information Technology
Office of Information Technology Help Desk Web Site University of Maryland Web Site Office of Information Technology Web Site