26.5 Basic remote execute functions
The PEcAn.remote::remote.execute.cmd
function runs a system command on a remote server (or on the local server, if host$name == "localhost"
).
x <- PEcAn.remote::remote.execute.cmd(host = my_host, cmd = "echo", args = "Hello world")
x
Note that remote.execute.cmd
is similar to base R’s system2
, in that the base command (in this case, echo
) is passed separately from its arguments ("Hello world"
).
Note also that the output of the remote command is returned as a character.
For R code, there is a special wrapper around remote.execute.cmd
– PEcAn.remote::remote.execute.R
, which runs R code (passed as a string) on a remote and returns the output.
code <- "
x <- 2:4
y <- 3:1
x ^ y
"
out <- PEcAn.remote::remote.execute.R(code = code, host = my_host)
For additional functions related to remote file operations and other stuff, see the PEcAn.remote
package documentation.