Operating System Information --> Unix (WAM and Glue) --> Unix Utilities --> Printing or Capturing the Output of a Program in Unix -->

Printing or Capturing the Output of a Program in Unix


The Script Utility

To capture screen output to a file use the command: script. This command starts a special shell whose screen input and output is redirected to both the screen and a file.

Run the commands to produce the desired output. Script runs using the sh shell. Never use a full screen editor while in a script shell. The resulting typescript file will be garbage. Backspaces and other cursor movements may also result in a less than perfect typescript 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, output should be in a file called typescript that you can send to a printer.


Common problems

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 do I:
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