Notice! This document is currently in Archived status.
The content of this document may be incorrect or out dated.

Capturing output for printing

There 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 > outdat
This method puts output into a file named outdat. The file can then be printed using the lp command:
	  lp outdat
To view the file use the cat or more commands:
	 cat outdat
more outdat

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 | lp
If 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 foo
The machine will respond:
	Script started, file is foo
Then run your program. When the program is done, type:
	exit
The machine will respond:
	Script done, file is foo
You 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 Unknown
Created: 2007/05/31 13:22:15.814000 GMT-4 by brian.r.brinegar.1.

Categories

Search

Type in a few keywords describing what information you are looking for in the text box below.

Admin Options: Edit this Document