[R] R CMD BATCH character limit?

Hsiu-Khuern Tang htang at hpl.hp.com
Wed Feb 2 19:00:58 CET 2005


* On Wed 10:39AM, 02 Feb 2005, Prof Brian Ripley (ripley at stats.ox.ac.uk) wrote:
> On Tue, 1 Feb 2005, Hsiu-Khuern Tang wrote:
> 
> >Is there a limit on the number of characters in an invocation like
> >
> >R CMD BATCH --opt1=val1 --opt2=val2 ... --save-to=C:\very\long\string 
> >..\R\script.R
> >
> >?
> 
> Yes, but that is not a valid invocation of R.
> 
> >I am running R 2.0.1 on Windows XP, and when running a long BATCH
> >command (about 400--500 characters) the last option gets mangled, as can
> 
> There is a Windows limit on the length of command lines, and I believe you 
> have hit it.  It looks like R.exe/Rcmd.exe were written assuming it is 
> MAX_PATH, hence about 260, which it used to be in Win95.
> 
> You could use
> 
> rterm --args --opt1=val1 --opt2=val2 ... --save-to=C:\very\long\string < 
> foo > bar
> 
> instead: BATCH is just a convenient shorthand (and see the rw-FAQ for the 
> details).

Thank you!  I tried this and it works (with the mandatory --save or
--no-save).  I also went back to the BATCH command and found that the
truncation occurred at the 217th character after the "R" of R CMD BATCH.

> 
> Shells also have limits, so check this for the one you used.
> 
> >be seen from a warning in script.Rout that looks like this:
> >
> >WARNING: unknown option
> >+--save-to=C:\very\long\str..\R\script.Rout
> >
> >Note that "string" is truncated to "str" _and_ concatenated with the
> >implicit batch output file "..\R\script.Rout".  (The "unknown option"
> >warning is expected; I am just using commandArgs() within the script to
> >pick out the arguments.)
> >
> >I have tried specifying --args before the options, with the same result,
> >except that the truncation appears earlier.
> 
> --args would be needed for this to make any sense.
> 
> -- 
> 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

Best,
Hsiu-Khuern.




More information about the R-help mailing list