[R] command line limit?

dederderian dederderian at micron.com
Tue Mar 25 18:08:00 CET 2003


Sorry, I thought I was replying to R-help.  
Anyways, you were correct.  I had already tried inserting a couple "\n"'s into the comfile with no luck.  I was still receiving the same error.  After your suggestion I inserted even more and it worked.

Regarding the suggestion of calling source(comfile), I didn't want to have to create a second comfile just to call another comfile.  Your suggestion would have worked though.  Knowing the actual limit is ~1022 is good info.  Now I can build that limit into my perl script.

Thanks for your help.
Dan

-----Original Message-----
From: Prof Brian D Ripley [mailto:ripley at stats.ox.ac.uk]
Sent: Tuesday, March 25, 2003 9:57 AM
To: dederderian
Cc: 'Martin Maechler'; 'r-help at stat.math.ethz.ch'
Subject: RE: [R] command line limit?


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