Article View: alt.msdos.programmer
Article #1151Formulated unclear : Re: Redirection of STDERR ??
From: Fred (Frot)
Date: Thu, 16 Nov 1995 13:13
Date: Thu, 16 Nov 1995 13:13
68 lines
2565 bytes
2565 bytes
Fred.Dullemond@Austria.ATTGIS.COM (Fred (Frot)) wrote:
>Hello,
>At the moment I am developing some kind of tool to call (spawn/exec)
>other commands (using swap of memory) in MS-DOS.
>In order not to disturb the screen by messages from the called program
>I use redirection of stdout.
> e.g. 'dir > \it.txt'
>I encountered a problem when this called program writes something to
>stderr. These messages are not redirected to the file, but corrupt the
>screen display and confuse the ignorant user.
>So I want to do something like under UNIX command-line :
> ls > /dev/null 2>&1
>or redirecting the stderr in the calling program to stdout (which I
>think would be the best), but I don't know how to do this.
> void main()
> {
> ......... // Some code
>
> fclose(stderr); // I know this does not work,
> // but the intention is closing the stderr for the next prog.
> spawnv(P_WAIT, .........) ; // Call the programm
> freopen(stderr), // Does not work either, but reopen the stderr
>is
> // needed for its own messages.
> ........... // Some error detection from spawn
> }
>If someone could shine some light on this, I would be very gratefull !
>Fred
>Fred.Dullemond@Austria.attgis.com
Thanks to all of you who reacted to my post.
I think the original post was a little bit unclear, since most of the
answers were concerning redirecting stderr WITHIN MSDOS, like
ctty nul
command-to-call
ctty con
But this is NOT what I want.
I am writing a C program that has a shell-function. I present the user
a menu with commands to select and within the C programm I call a
SPAWN/EXEC.. c-function which handles the called programm.
Once this called programm has finished, my programm goes on.
Since I want MY program (shell) to handle all the screen output, the
called programs output must be captured somehow.
So I need some C-CODE which allows me to redirect the stderr &| stdout
to something else.
Fred
Technical Details
Message-ID:
<DI50nF.AwH@news.zippo.com>Path:
arc1-ca.pugleaf.net!news3.noc.netcom.net!zdc!zippo!usenetReferences:
<DI3BnA.JF5@news.zippo.com>Show Full Headers
Complete Article Headers
Newsgroups: alt.msdos.programmer,comp.lang.c,comp.msdos.programmer,comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!news3.noc.netcom.net!zdc!zippo!usenet From: Fred.Dullemond@Austria.ATTGIS.COM (Fred (Frot)) Subject: Formulated unclear : Re: Redirection of STDERR ?? X-Newsreader: Forte Free Agent 1.0.82 Sender: usenet@news.zippo.com Nntp-Posting-Host: 192.127.84.153 Organization: Zippo Message-ID: <DI50nF.AwH@news.zippo.com> References: <DI3BnA.JF5@news.zippo.com> Date: Thu, 16 Nov 1995 13:13:24 GMT