Subject: Re: Redirect the stderr GCC stream to file, executing from Ms-Dosshell
From: [email-masked] (Chris Faylor)

2 Oct 1997 06:22:39 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Reply-To: [email-masked]
To: [email-masked]

In article <[email-masked]>, Chris Faylor <[email-masked]> wrote:
>In article <[email-masked]>,
>Sergey Okhapkin  <[email-masked]> wrote:
>>Chris Faylor wrote:
>>> In article <[email-masked]>,
>>> Giandomenico De Sanctis <[email-masked]> wrote:
>>> >How to redirect the stderr stream to a file, running GCC from MS-Dos
>>> >command prompt, and not from Unix-like shell as bash??
>>> 
>>> gcc whatever 2>wherever
>>
>>This works with NT4.0 cmd.exe only, but not with 95's command.com.
>
>Right.  Sorry to have not mentioned that.
>
>Other alternatives are:
>
>1) Use 4DOS ( http://www.jpsoft.com ), which allows '>&' for redirection.
>
>2) Write a small program to redirect stderr to stdout and run its
>   arguments.

Just to follow up on my own points:  The command I gave originally
does work on NT 3.51.  That's all I'm running here.

Someone asked for the small program.  This is it:

Create a file called 'stderr.c':

int
main(int argc, char **argv)
{
  dup2(1, 2);
  argv++;
  execvp(*argv, argv);
  perror(*argv);
  exit(1);
}

Compile this:

gcc -o stderr -g stderr.c

The program stderr will redirect all error output to the same place as
stdout:

stderr gcc -c stderr.c > gcc.out

This will probably only work with cygwin.dll programs, though.

In a vain attempt to hold off on future messages, I'd like to point out
that I know that it is possible to make this into a much more sophisticated
program which takes an argument signifying a file for the stderr output.
It is possible to augment this program to shine your shoes and walk the dog.
There are undoubtedly much more sophisticated programs out there which
will do exactly what is required and do it intuitively without even the
necessity of typing the command at all.

Personally, I would again strongly suggest that anyone who can't use
bash for this should consider 4DOS.  It is a wonderful command line
shell which provides you all sorts of advanced capabilities lacking in
command.com or cmd.exe.

	http://www.jpsoft.com
-- 
http://www.bbc.com/	[email-masked]			"Strange how unreal
VMS=>UNIX Solutions	Boston Business Computing	 the real can be."
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".