Discussion Locked

Saving outputs of C programs

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Anyone knows a free application that will let
me save out put of C/C++ programs executed
from a dos prompt?

Thanks,

13 replies

by alphacentauri

Sounds like you want to redirect output.
If so, try this:

someprog.exe > foo

Anything written to stdout will now be written to foo

by ryttinch

If you want to save the output of a c/c++ program using bourne/korn/bash shells, the following will work

for stdout ...
program > out.file

for stderr ...
program 2> err.file

if you want to send both to the same file, try:

program > out.file 2>&1

If you are using csh/tcsh you won't be able to differenciate between stdout and stderr, so

program > out.file

will give you stdout and stderr to the same file.

Good luck,

Chad Rytting

by thuong.luu

I need solutions for a dos application.
At this time, the only way I can do is
save each screen into a Word document
and it is tedious.

by alphacentauri

Another potential solution would be to use expect (this is a unix tool, but I believe it has been ported to DOS). Check the GNU tools at cygnus to verify that it is indeed part of the toolset.

Alternatively, you could write your own small programthat uses popen to 'open' the program, then read/write from the target program dumping the resulting dialog to to a file.

by asjwm2

Dear Thuong,
The standard ouput redirect "<" will work,
however it will not show any prompts. If the
user input is simple, the user can remember
it and type it in just like a regular
program, but will not see anything on the
screen. But, if the program requires
complicated user input, you probably could
write a "script" that reversed the redirect
for input.

by brett feldon

This question was posted in the Unix section. If you are running DOS, this solution certainly won't work.

On some Unix variants, you can make an transcript of everything done at a shell prompt with the script program. Run script [filename] (without the []), then play around with commands, then press the EOF character to stop script. EOF is usually set to Ctrl-D.

Note that this solution doesn't affect the output of prompts etc: you can use the program normally.

by tony derosa

BTW: redirection works from the DOS prompt as well:

D:\jdksrc>java OperatingSystemCommand >tttt

D:\jdksrc>type tttt

***************************************************

System Info

***************************************************

The OS Name : Windows NT
The OS Architecture: x86
The OS Version : 4.0
The JRE Version : 1.2.2
The JVM Version : 1.2.2
The User Name : aderosa
The Domain name : WSUS111W17A008

D:\jdksrc>

This discussion is closed to new replies.