On Thu, 10 Nov 2005, paul sorenson wrote: > Angelo Secchi wrote: >> >> On Wed, 09 Nov 2005 12:25:37 -0000 (GMT) >> (Ted Harding) <[EMAIL PROTECTED]> wrote: >> >> >>> On 09-Nov-05 Roger Bivand wrote: >>> >>>> On Wed, 9 Nov 2005, Angelo Secchi wrote: >>>> >>>>> Hi, >>>>> I wrote a small R script (delta.R) using commandArgs(). The script >>>>> works from the shell in usual way >>>>> >>>>> R --no-save arg1 < delta2.R >>>>> >>>>> Suppose arg1 is the output of another shell command (e.g. gawk, >>>>> sed ...). Is there a way to tell R to read arg1 from the >>>>> output of the previous command? Any other workaround? >>>> >>>> Use shell variables, possibly also Sys.getenv() within R as well as or >>>> instead of commandArgs(). >>> >>> If it's a fairly simple shell comand (and even if it isn't, though >>> it could get tricky for complicated ones) you can use the "backquote" >>> trick (called, in well-spoken circles, "command substitution"): >>> >>> R --no-save `shellcmd` < delta2.R >>> >>> As in all shell command lines, wherever you have a command (including >>> arguments etc.) between backquotes, as exemplified by "`shellcmd`" above, >>> the output of the command (as sent to stdout) replaces "`shellcmd`" in >>> the command-line. This could be a lot of stuff (depending on what >>> "shellcmd" is), or just one value, or whatever. > > ... and this behaviour is OS (or at least command shell specific) for > anyone trying this on Windows and wondering why it doesn't work.
But it does work on Windows if you have a reasonable shell. Cmd.exe is and (especially) command.com are not shells in the usually accepted sense. Better to use Rterm than incur the additional overhead of R, though. -- Brian D. Ripley, [EMAIL PROTECTED] 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 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html