Computing.Net > Forums > Disk Operating System > Capturing output from a dos program

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Capturing output from a dos program

Reply to Message Icon

Name: scott
Date: January 12, 2002 at 10:52:36 Pacific
Comment:

Does anyone know how to get the output of a dos program. That way it can be used as data for another program.



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: January 12, 2002 at 12:06:58 Pacific
Reply:

command > file
or
command >> file

e.g.:

dir > out.txt
or
dir >> out.txt

Using two greater-then signs will APPEND the output to the file (will preserve previous data from file).
Using only one will "reset" file and put only the output (if there where any data in the file, it will be lost)

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: Jim
Date: January 12, 2002 at 12:23:22 Pacific
Reply:

There are 3 ways to use text output from a
DOS program.

1. Use the right arrow,>,to send the text to
a file. For example to save the contents
of a directory type, dir>dir.txt. This
redirects the output to the file you
choose,in this case dir.txt. Your
program then can read the file.

2. Use the left arrow, <, to use a file such
as dir.txt from above to send file
contents to the input of your program. For
example type, dir.txt < yourprog. Then
yourprog code would read the file just as
if you typed the info yourself using the
normal keyboard input functions. Of course
you could also add code to open the file
and read it but this is a shortcut

3. Use the pipe symbol, | , to use the output
of another program to input directly to
yours. Then your program can input the
text as if it came from the keyboard. In
C it would be getch() for 1 character at
a time or gets() to read an etire line.
Keep reading until you get a NULL. For
example type dir | yourprog. Then
yourprog code reads the directory listing
the same way you would as if you typed it
in yourself.


0

Response Number 3
Name: sekirt
Date: January 13, 2002 at 23:21:02 Pacific
Reply:

If you are saying that you have a DOS program that spits out some info - but offers no way to print or save to disk, then no. No way to save, except maybe print screen.

If it offers to print the data there was a program called PRN2FILE which would redirect anything going to the printer to a file on disk.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Capturing output from a dos program

Printing from a dos program www.computing.net/answers/dos/printing-from-a-dos-program/14856.html

Capturing screen text in DOS www.computing.net/answers/dos/capturing-screen-text-in-dos/11017.html

Controlling A DOS Program From Windows www.computing.net/answers/dos/controlling-a-dos-program-from-windows/16993.html