The content of this document may be incorrect or out dated.
Capturing output for printingThere are several ways to capture your program's output in a file.
The first way is to use "output redirection". The redirect command (>) will redirect the output from the program into a file. If your program does require you to type in data at the keyboard you will not see the prompts.
a.out > outdatThis method puts output into a file named outdat. The file can then be printed using the lp command:
lp outdatTo view the file use the cat or more commands:
The same data may be routed directly to the printer without storing it in a file. This is done using the pipe (|) character to direct the command output to another device:
a.out | lpIf you need to enter data from the keyboard, you probably want to use the script command. Script makes a copy of everything that is printed on your terminal. To use script, type this command:
script fooThe machine will respond:
Script started, file is fooThen run your program. When the program is done, type:
exitThe machine will respond:
Script done, file is fooYou can then view the file on your terminal screen or print the output file on a printer, just as you would any other file.
Last modified: 2007/05/31 13:22:15.814000 GMT-4 by
Created: 2007/05/31 13:22:15.814000 GMT-4 by brian.r.brinegar.1.
Type in a few keywords describing what information you are looking for in the text box below.