Article View: alt.msdos.programmer
Article #1304Re: Redirecting output of DOS batch files
From: Floyd Miller
Date: Sat, 10 Mar 1990 21:42
Date: Sat, 10 Mar 1990 21:42
38 lines
1999 bytes
1999 bytes
I appreciate the responses both via email and followup articles.
The use of COMMAND /C certainly satisfies the problem in my
original posting: redirecting the output from a batch file.
The ensuing discussion on the use of the /C option with EXEC
and SPAWN was also interesting.
A second operation I discovered I needed was a way to redirect
the stderr output. Unix shells provide the means to accomplish
this but apparently not COMMAND.COM.
Using the examples of EXEC to invoke COMMAND.COM from within a C
program I am writing a REDIR program which will combine stderr
with stdout so both can be redirected to the same place. At least
that partially solves the problem. I'm not worried right now about
redirecting them separately. Once I'm finished I'll submit it to
C.B.I.P for posting - if I can figure out how to do that.
I found a problem with the code posted for exec'ing COMMAND.COM. Using:
execlp("COMMAND.COM", "/C", cmd_string, NULL);
starts up COMMAND.COM interactively and results in an error message:
Specified MS-DOS search directory bad.
I discovered, experimentally that what is required is:
execlp("COMMAND.COM", "COMMAND.COM", "/C", cmd_string, NULL);
so that the 1st argument passed to COMMAND.COM is its name.
I hope this helps anyone else whose had a similar problem.
******* *****************************************
***** ************************* Floyd Miller
*** *************** floyd@starsend.UUCP
* ********* floyd%starsend@PRC.Unisys.com
*** starsend!floyd@burdvax.PRC.Unisys.com
*
Technical Details
Message-ID:
<0020@starsend.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!wuarchive!udel!burdvax!starsend!floydShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!wuarchive!udel!burdvax!starsend!floyd From: floyd@starsend.UUCP (Floyd Miller) Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc.programmer Subject: Re: Redirecting output of DOS batch files Message-ID: <0020@starsend.UUCP> Date: 10 Mar 90 21:42:16 GMT Followup-To: alt.msdos.programmer Organization: Woodward McCoach, Inc. Lines: 38