Solved

redirect _spawnl() to file

Posted on 1998-10-07
1
336 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Inorder binary search tree 5 164
Need example 5 114
An API detour question 7 85
Incompatible types when assigning to type 'complex' from type 'complex' 21 12
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…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops 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.

777 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