Below is an example showing how the exact same call can be done in a Unix shell as in a Windows shell.
All that is required is that the myscript.R
is in the same folder as myscript
and myscript.bat
.
This makes it easier to document and easier to give examples.
Note, for it to work on Unix without having to specify ./myscript
when calling it from the same directory,
the current diectory has be part of the PATH
, e.g. export PATH=".:$PATH"
. If myscript
is placed in
a folder that is already in the PATH
, the below will work out of the box.
$ myscript 1 "2" "3 ab"
myscript.R: Hello world!
[1] "/usr/lib/R/bin/exec/R" "--slave" "--no-restore"
[4] "--file=./myscript.R" "--args" "1"
[7] "2" "3 ab"
and also
$ path/to/myscript 1 "2" "3 ab"
myscript.R: Hello world!
[1] "/usr/lib/R/bin/exec/R" "--slave" "--no-restore"
[4] "--file=./myscript.R" "--args" "1"
[7] "2" "3 ab"
Note how you do not have to specify the *.bat
extension when calling a BAT script.
> myscript 1 "2" "3 ab"
myscript.R: Hello world!
[1] "C:\\PROGRA~1\\R\\R-34~1.2\\bin\\x64\\Rterm.exe"
[2] "--slave"
[3] "--no-restore"
[4] "--file=myscript.R"
[5] "--args"
[6] "1"
[7] "2"
[8] "3 ab"
and also
> path\to\myscript 1 "2" "3 ab"
myscript.R: Hello world!
[1] "C:\\PROGRA~1\\R\\R-34~1.2\\bin\\x64\\Rterm.exe"
[2] "--slave"
[3] "--no-restore"
[4] "--file=myscript.R"
[5] "--args"
[6] "1"
[7] "2"
[8] "3 ab"