[R] R 2.5.1 - Rscript through tee

François Pinard pinard at iro.umontreal.ca
Mon Aug 27 04:47:18 CEST 2007


Hi, people.

I met a little problem for which someone might have a solution.  Let's 
say I have an executable file (named "pp.R") with this contents:

   #!/usr/bin/Rscript
   options(echo=TRUE)
   a <- 1
   Sys.sleep(3)
   a <- 2

If I execute "./pp.R" at the shell prompt, the output shows the timely 
progress of the script as expected.  If I use "./pp.R | tee OUT" 
instead, the output seems buffered and I see it all at once at the end.

The problem does not come from the "tee" program, as if I use this 
command:

   (echo a; sleep 5; echo b) | tee OUT

the output is timely, not batched.

So, is there a way to tell R (or Rscript) that standard output should be 
unbuffered, even if it is not directly connected to a terminal?

In case useful, here is local R information:

Version:
 platform = x86_64-unknown-linux-gnu
 arch = x86_64
 os = linux-gnu
 system = x86_64, linux-gnu
 status = 
 major = 2
 minor = 5.1
 year = 2007
 month = 06
 day = 27
 svn rev = 42083
 language = R
 version.string = R version 2.5.1 (2007-06-27)

Locale:
LC_CTYPE=fr_CA.UTF-8;LC_NUMERIC=C;LC_TIME=fr_CA.UTF-8;LC_COLLATE=fr_CA.UTF-8;LC_MONETARY=fr_CA.UTF-8;LC_MESSAGES=fr_CA.UTF-8;LC_PAPER=fr_CA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_CA.UTF-8;LC_IDENTIFICATION=C

Search Path:
 .GlobalEnv, package:stats, package:utils, package:datasets, fp.etc, package:graphics, package:grDevices, package:methods, Autoloads, package:base

-- 
François Pinard   http://pinard.progiciels-bpi.ca



More information about the R-help mailing list