public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: cgf@bbc.com (Chris Faylor)
To: gnu-win32@cygnus.com
Subject: Re: Redirect the stderr GCC stream to file, executing from   Ms-Dosshell
Date: Thu, 02 Oct 1997 05:57:00 -0000	[thread overview]
Message-ID: <EHFCsE.1I9@bbc.com> (raw)
In-Reply-To: <EHDp53.37t@bbc.com>

In article < EHDp53.37t@bbc.com >, Chris Faylor <cgf@bbc.com> wrote:
>In article <01BCCE53.F7289290@gater.krystalbank.msk.ru>,
>Sergey Okhapkin  <sos@prospect.com.ru> wrote:
>>Chris Faylor wrote:
>>> In article <199709301048.MAA00599@ammi.mclink.it>,
>>> Giandomenico De Sanctis <mc4420@mclink.it> 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/	cgf@bbc.com			"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
"gnu-win32-request@cygnus.com" with one line of text: "help".

  reply	other threads:[~1997-10-02  5:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-30 23:23 Sergey Okhapkin
1997-10-01  8:18 ` Chris Faylor
1997-10-02  5:57   ` Chris Faylor [this message]
1997-10-01 16:44 ` Rick Frink
1997-10-01 12:32 John Cook
1997-10-02  1:08 mark
1997-10-02  5:46 Chris Faylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EHFCsE.1I9@bbc.com \
    --to=cgf@bbc.com \
    --cc=gnu-win32@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).