passing args from the command line

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

passing args from the command line

r_a_mueller
Happy New Year to all!

I want to run a script from a directory on a central server on different
machines, linux and windows. To determine which machine is calling the script
I want to pass an argument with the call (e.g. for choosing the display
device, for writing path names etc.)
I tried the following:
R CMD BATCH --args gui=4 /home/script.R script.out (linux)
resp. Rcmd BATCH --args gui=1 Z:/script.R script.out (windows)

The script started with
args(commandArgs(TRUE)) # thanks to James Forester for his R-concerning blog

script.out says: Error in commandArgs(TRUE): unused argument(s) (linux)
windows says: input file --args cannot be opened

Something must be going wrong (but different things on Win and Linux) (but
what?)
Richard

--
Richard Müller - Am Spring 9 - D-58802 Balve-Eisborn
www.oeko-sorpe.de

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: passing args from the command line

Uwe Ligges


Richard Müller wrote:
> Happy New Year to all!
>
> I want to run a script from a directory on a central server on different
> machines, linux and windows. To determine which machine is calling the script
> I want to pass an argument with the call (e.g. for choosing the display
> device, for writing path names etc.)
> I tried the following:
> R CMD BATCH --args gui=4 /home/script.R script.out (linux)
> resp. Rcmd BATCH --args gui=1 Z:/script.R script.out (windows)

Note the help page
R CMD BATCH --help

You probably want

   R CMD BATCH "--args gui=1" Z:/script.R script.out
or
   R --no-save --args gui=1 < Z:/script.R > script.out


Uwe Ligges



> The script started with
> args(commandArgs(TRUE)) # thanks to James Forester for his R-concerning blog
>
> script.out says: Error in commandArgs(TRUE): unused argument(s) (linux)
> windows says: input file --args cannot be opened
>
> Something must be going wrong (but different things on Win and Linux) (but
> what?)
> Richard
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.