Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

redirect _spawnl() to file

Posted on 1998-10-07
1
Medium Priority
?
344 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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

636 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