In MS Windows I
a) invoke Rterm from a batch file (test.bat)
b) to execute commands from a script (m:\test.rsc)
c) capturing output in a log file (m:\test.log)
BUT if the script results in an error the error message is NOT written to
the log file, leaving me problems when the error is from a complicated
function.
Simplified example:.
test.bat ------------------------
REM ensure 'R' is in path
path \\Server02\stats\R\R-Current\bin\;%PATH%
Rterm --no-init-file --no-restore-data --no-save --silent < m:\test.rsc >
m:\test.log
---------------------
m:\test.rsc -----------------
print("this is a test")
#generate an error
nls()
------------------
The error message:
"Error in .Internal(inherits(x, what, which)) : 'x' is
missing"
is is NOT written to the log file, which just ends
m:\test.log --------------------------
<snip>> print("this is a test")
[1] "this is a test"> #generate an error
> nls()
---------------------
I surmise this is due to output buffering (?). In an S-Plus version I turned
off buffering with
guiSetOption(option.name="BufferOutputWindows",
value.string="F")
but I don't think this is available in R (?).
Has anyone any suggestions?
Thanks in advance,
Keith Jewell
--please do not edit the information below--
R Version:
platform = i386-pc-mingw32
arch = i386
os = mingw32
system = i386, mingw32
status major = 2
minor = 11.0
year = 2010
month = 04
day = 22
svn rev = 51801
language = R
version.string = R version 2.11.0 (2010-04-22)
Windows Server 2003 x64 (build 3790) Service Pack 2
Locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
Search Path:
.GlobalEnv, package:datasets, CBRIForecast, package:RODBC, package:tree,
package:locfit, package:lattice, package:akima, package:nlme, package:MASS,
package:grDevices, package:geometry, KJRutils, package:xlsReadWrite,
package:svSocket, package:TinnR, package:R2HTML, package:Hmisc,
package:survival, package:splines, package:graphics, package:stats,
CBRIutils, package:utils, package:tcltk, package:tools, package:methods,
TempEnv, Autoloads, package:base
Keith Jewell wrote:> In MS Windows I > a) invoke Rterm from a batch file (test.bat) > b) to execute commands from a script (m:\test.rsc) > c) capturing output in a log file (m:\test.log) > BUT if the script results in an error the error message is NOT written to > the log file, leaving me problems when the error is from a complicated > function. > > Simplified example:. > > test.bat ------------------------ > REM ensure 'R' is in path > path \\Server02\stats\R\R-Current\bin\;%PATH% > Rterm --no-init-file --no-restore-data --no-save --silent < m:\test.rsc > > m:\test.log > --------------------- > > m:\test.rsc ----------------- > print("this is a test") > #generate an error > nls() > ------------------ > > The error message: > "Error in .Internal(inherits(x, what, which)) : 'x' is missing" > is is NOT written to the log file, which just ends > > m:\test.log -------------------------- > <snip> > >> print("this is a test") >> > [1] "this is a test" > >> #generate an error >> nls() >> > --------------------- > > I surmise this is due to output buffering (?). In an S-Plus version I turned > off buffering with > guiSetOption(option.name="BufferOutputWindows", value.string="F") > but I don't think this is available in R (?). > > Has anyone any suggestions?It's not output buffering, it's because error messages go to a different file handle than regular ones. You need to redirect both stdout and stderr. I'm not sure of the syntax to do that in Windows CMD, but R CMD BATCH test.rsc instead of Rterm would do it. (The output should go to test.Rout.) Duncan Murdoch
On Thu, 10 Jun 2010, Keith Jewell wrote:> In MS Windows I > a) invoke Rterm from a batch file (test.bat) > b) to execute commands from a script (m:\test.rsc) > c) capturing output in a log file (m:\test.log) > > BUT if the script results in an error the error message is NOT written to > the log file, leaving me problems when the error is from a complicated > function.Sure, warning and errors are written to stderr, which you did not redirect. This is covered in rw-FAQ Q2.12. Using R CMD BATCH would have done this for you .... This is not to do with 'buffered output': in any case R uses minimal buffering so stdout and stderr can be mixed nicely on a single log file.> Simplified example:. > > test.bat ------------------------ > REM ensure 'R' is in path > path \\Server02\stats\R\R-Current\bin\;%PATH% > Rterm --no-init-file --no-restore-data --no-save --silent < m:\test.rsc > > m:\test.log > --------------------- > > m:\test.rsc ----------------- > print("this is a test") > #generate an error > nls() > ------------------ > > The error message: > "Error in .Internal(inherits(x, what, which)) : 'x' is missing" > is is NOT written to the log file, which just ends > > m:\test.log -------------------------- > <snip> >> print("this is a test") > [1] "this is a test" >> #generate an error >> nls() > --------------------- > > I surmise this is due to output buffering (?). In an S-Plus version I turned > off buffering with > guiSetOption(option.name="BufferOutputWindows", value.string="F") > but I don't think this is available in R (?). > > Has anyone any suggestions? > > Thanks in advance, > > Keith Jewell > --please do not edit the information below-- > > R Version: > platform = i386-pc-mingw32 > arch = i386 > os = mingw32 > system = i386, mingw32 > status > major = 2 > minor = 11.0 > year = 2010 > month = 04 > day = 22 > svn rev = 51801 > language = R > version.string = R version 2.11.0 (2010-04-22) > > Windows Server 2003 x64 (build 3790) Service Pack 2 > > Locale: > LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United > Kingdom.1252;LC_MONETARY=English_United > Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 > > Search Path: > .GlobalEnv, package:datasets, CBRIForecast, package:RODBC, package:tree, > package:locfit, package:lattice, package:akima, package:nlme, package:MASS, > package:grDevices, package:geometry, KJRutils, package:xlsReadWrite, > package:svSocket, package:TinnR, package:R2HTML, package:Hmisc, > package:survival, package:splines, package:graphics, package:stats, > CBRIutils, package:utils, package:tcltk, package:tools, package:methods, > TempEnv, Autoloads, package:base > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Reasonably Related Threads
- Intermittent failures mapping drives.. need debugging help/sugges tions
- Winbind in Multiple-Forests - Super Admin Domain Model
- Storage compression patch for Rsync (unfinished)
- update.packages on MS Windows with //server/share paths
- UNC windows path beginning with backslashes: normalizePath bug??