Skip to content

capture stderr in Windows

5 messages · Moises Hassan, Uwe Ligges, Duncan Murdoch +1 more

#
On Mon, 16 Aug 2004 10:25:08 -0700, "Moises Hassan"
<mhassan at scitegic.com> wrote :
That depends on your shell.  The standard Windows command shell
COMMAND.COM or CMD.EXE provides no easy way to do this.  There are
lots of replacement shells around that can do it; I use Cygwin's bash
shell most of the time.

There are also programs on the net that do nothing but redirect
standard handles, e.g. <http://www.commandline.co.uk/mtee/index.html>.
I've never tested these.

Duncan Murdoch
#
Moises Hassan wrote:

            
"Rterm --no-save --no-restore < "Rscriptfile" 2>&1 "Rstdoutfile"

I'd rather use R CMD BATCH anyway.

Uwe Ligges
#
I wrote the message below, but it's just plain wrong.

The CMD.EXE shell in Win XP (and 2K?) allows redirection of stderr in
the usual Unix style:

  Rterm --no-save --no-restore < "Rscriptfile" > "Rstdoutfile"
2>"Rstderrfile"

You can also use "2>&1" to redirect stderr into the stdout stream, so
both go to Rstdoutfile.

Duncan Murdoch
#
On Mon, 16 Aug 2004, Duncan Murdoch wrote:

            
(Yes, all NT-based versions of Windows.)
[But the order matters, so first redirect stdout and then redirect stderr 
to stdout.]

And for completeness, 

1) Under non-NT Windows (95/98/ME) stderr is the same as stdout since its 
shells don't know about stderr.

2) This is in all the rw-FAQ, Q2.10