?
Solved

redirect _spawnl() to file

Posted on 1998-10-07
1
Medium Priority
?
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

800 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