Skip to content Accesskey=4Skip to sub-navigation Accesskey=3View our Accessibility Options MIT Information Systems Home About IS&T Contact IS&T Site Map Search Advanced Search
Getting StartedGetting Services by Topic or Alphabetically Getting Help

On This Page

[Help]

  

Quick Links

Top Level

Related Links

Ask OLC a question

Athena Consulting Homepage

Helpdesk Stock Answers (for Mac/PC questions)


How to capture a copy of the output (for PRINTING)

There are two ways to capture your program's output in a file.

The first way is to use "output redirection".  If your program does not
require you to type in data at the keyboard, you can redirect the output from
the program into a file by typing this command:

	a.out > foo

This method puts output into a file named 'foo'; it does not display anything
on your screen.

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', first type this command:

	script foo

The machine will respond:

	Script started, file is foo

Then run your program normally.  When the program is done, type:

	exit

The machine will respond:

	Script done, file is foo

You can use the 'more' command to view the file on your terminal screen, or
you can print the output file on a printer as you would any other file.

MIT Home | Getting Started | Getting Services | Getting Help | About IS&T | Accessibility
Ask a technology question or send a comment about this web page.