Re: [R] Run Rscript.exe, how to capture error message?

From: Prof Brian Ripley <>
Date: Wed, 09 Jun 2010 06:51:18 +0100 (BST)

R error messages go to stderr, not stdout, so you need to redirect the latter. In most shells, including cmd.exe (which as you don't say is likely what you are using) you can use

Rscript test.R xxx.txt > error.log 2>&1

to redirect both stdout and stderr to the same file (see the rw-FAQ Q2.12).

On Tue, 8 Jun 2010, A Huang wrote:

> Hi there,
> I use Rscript.exe for batch run (actually it is used in code)
> c:>"C:\Program Files\R\R-2.10.1\bin\Rscript.exe" test.r xxx.txt
> Where test.r is the r program and xxx.txt is a file name test.r will read in, it comes from
> a web form. This works fine, when the file is in required format. Sometime, xxx.txt
> has wrong format, test.r read in but can't process it. If I run interactive mode, I
> probably can see the error message on the screen. But since this is running
> as a background process, I don't really have a screen to see.
> I tried redirct:
> c:>"C:\Program Files\R\R-2.10.1\bin\Rscript.exe" test.r xxx.txt > error.log
> But it doesn't work even in local windows.
> Thanks
> A. Huang

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 09 Jun 2010 - 05:53:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Jun 2010 - 07:50:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive