Access Keys:
Skip to content (Access Key - 0)

How can I save a copy of my program's output?

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:

	executable_name > log.txt

where "executable_name" is the name of your program. This method puts output into a file named 'log.txt'; it does not display anything (except errors) on your screen.

If you need to enter data from the keyboard, you probably want to use the
"script" command, which stores a script of your terminal session, recording both input and output, exactly as you typed it, including control characters (ie: carriage returns). To begin capturing input and output, simply type "script" followed by the name of the file you wish to save the output to:

joeuser@athena:~$ script myoutput.txt
Script started, file is myoutput.txt

You'll then get your shell prompt back (a new shell is started). After you run your commands, exit the shell by typing "exit" or pressing Ctrl-D.

joeuser@athena:~$ exit
Script done, file is myoutput.txt

You can then examine the output of the file using any text editor.

IS&T Contributions

Documentation and information provided by IS&T staff members


Last Modified:

February 25, 2009

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
Labels:
program program Delete
output output Delete
save save Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
Feedback
This product/service is:
Easy to use
Average
Difficult to use

This article is:
Helpful
Inaccurate
Obsolete
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki