runCmd: Run command via Bash directly from R

Description Usage Arguments Value Examples

Description

Allows users to run Bash commands directly from within R. This will only work in WIndows if WSL has been set up.

Usage

1
runCmd(cmd, intern = FALSE, wait = TRUE)

Arguments

cmd

the system command to be invoked, as a character string.

intern

a logical (not NA) which indicates whether to capture the output of the command as an R character vector.

wait

a logical (not NA) indicating whether the R interpreter should wait for the command to finish, or run it asynchronously. This will be ignored (and the interpreter will always wait) if intern = TRUE.

Value

If intern = TRUE, a character vector giving the output of the command, one line per character string. (Output lines of more than 8095 bytes will be split). If the command could not be run an R error is generated. Under the Rgui console intern = TRUE also captures stderr. If command runs but gives a non-zero exit status this will be reported with a warning and in the attribute "status" of the result: an attribute "errmsg" may also be available. If intern = FALSE, the return value is an error code (0 for success), given the invisible attribute (so needs to be printed explicitly). If the command could not be run for any reason, the value is 127. Otherwise if wait = TRUE the value is the exit status returned by the command, and if wait = FALSE it is 0 (the conventional success value).

Examples

1
2
runCmd("ls")
runCmd("ls", intern = TRUE)

anilchalisey/juggleR documentation built on May 9, 2019, 4 a.m.