[R] command line limit?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Tue Mar 25 17:56:45 CET 2003

On Tue, 25 Mar 2003, dederderian wrote:

> Very insightful.  Thanks Martin.
> Maybe, I need to explain my problem a little better.

Yes, please do: you seem to be talking about console input lines, not the
command line at all.

> I am creating an R comfile within a perl script.
> When I run this R comfile using:
>     source("Rcomfile.txt")
> It works fine.
> When I run it from within my perl script using:
>     R --no-save < Rcomfile.txt
> It does not work.
> I receive this error message in the middle of a long command line:
>     Error: syntax error
>     Execution halted
> I only see this problem when I have really "long" command lines within the comfile.
> I don't really have a work around for getting rid of my long command lines so I would like to find a way to make this work.

Why can't you call source() in Rcomfile.txt?

AFAIK there is a 1022 char limit on input lines at the console, including
redirected.  From src/unix/system.txt

 *  2. CONSOLE I/O
 *  The first group of functions is concerned with reading and
 *  writing to the system console.
 *    int   R_ReadConsole(char *prompt, char *buf, int buflen, int hist)
 *  This function prints the given prompt at the console and then
 *  does a gets(3)-like operation, transferring up to "buflen" characters
 *  into the buffer "buf".  The last two characters are set to "\n\0"
 *  to preserve sanity.

and buflen is 1024 in src/main/main.c

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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list