Solved

redirect _spawnl() to file

Posted on 1998-10-07
1
333 Views
Last Modified: 2008-03-17
I'm using MSVC 1.52 to create a DOS app.
I'm trying to call a DOS program and redirect the output to a text file.  For example, from a DOS command line:
C:\PROG.EXE PARM1 > C:\TEMPFILE.TMP

The code I'm using is:
_spawnl(_P_WAIT, "C:\\PROG.EXE","PARM1 > C:\\TEMPFILE.TMP", NULL)

No error is returned from _spawnl, but the file does not contain the contents of program output.

Is it possible to do this? or am I calling _spawnl incorrectly?
0
Comment
Question by:garywilkinson
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1253406
It is possible to redirect output of a child process to a file, but not ny using spawnl

DOS redirection is handled by the DOS shell thru some low level tinkering (spawnl doesn't know about this)

Under DOS this should work
system( "C:\\PROG.EXE PARAM1 > C:\\TEMPFILE.TMP" ) ;
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now