Start an external process in the background, and report its completion via a deferred.
run_process(
command = NULL,
args = character(),
error_on_status = TRUE,
wd = NULL,
env = NULL,
windows_verbatim_args = FALSE,
windows_hide_window = FALSE,
encoding = "",
...
)
Character scalar, the command to run. If you are
running .bat
or .cmd
files on Windows, make sure you read the
'Batch files' section in the process manual page.
Character vector, arguments to the command.
Whether to reject the referred value if the program exits with a non-zero status.
Working directory of the process. If NULL
, the current
working directory is used.
Environment variables of the child process. If NULL
,
the parent's environment is inherited. On Windows, many programs
cannot function correctly if some environment variables are not
set, so we always set HOMEDRIVE
, HOMEPATH
, LOGONSERVER
,
PATH
, SYSTEMDRIVE
, SYSTEMROOT
, TEMP
, USERDOMAIN
,
USERNAME
, USERPROFILE
and WINDIR
. To append new environment
variables to the ones set in the current process, specify
"current"
in env
, without a name, and the appended ones with
names. The appended ones can overwrite the current ones.
Whether to omit the escaping of the command and the arguments on windows. Ignored on other platforms.
Whether to hide the window of the application on windows. Ignored on other platforms.
The encoding to assume for stdout
and
stderr
. By default the encoding of the current locale is
used. Note that processx
always reencodes the output of
both streams in UTF-8 currently.
Extra arguments are passed to process$new()
, see
process. Note that you cannot pass stout
or stderr
here,
because they are used internally by run()
. You can use the
stdout_callback
, stderr_callback
, etc. arguments to manage
the standard output and error, or the process class directly
if you need more flexibility.
Deferred object.
if (FALSE) { # \dontrun{
afun <- function() {
run_process("ls", "-l")$
then(function(x) strsplit(x$stdout, "\r?\n")[[1]])
}
synchronise(afun())
} # }