system invokes the OS command specified by command.
system(command, intern = FALSE,
ignore.stdout = FALSE, ignore.stderr = FALSE,
wait = TRUE, input = NULL, show.output.on.console = TRUE,
minimized = FALSE, invisible = TRUE, timeout = 0)
| Parameter | Description |
|---|---|
command |
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. |
ignore.stdout, ignore.stderr |
a logical (not NA) indicating whether messages written to stdout or stderr should be ignored. |
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. When running the command asynchronously, no output will be displayed on the Rgui console in Windows (it will be dropped, instead). |
input |
if a character vector is supplied, this is copied one string per line to a temporary file, and the standard input of command is redirected to the file. |
timeout |
timeout in seconds, ignored if 0. This is a limit for the elapsed time running command in a separate process. Fractions of seconds are ignored. |
show.output.on.console, minimized, invisible |
arguments that are accepted on Windows but ignored on this platform, with a warning. |
show.output.on.console |
logical (not NA), indicates whether to capture the output of the command and show it on the R console (not used by Rterm, which shows the output in the terminal unless wait is false, and on some systems even when wait is false). |
minimized |
logical (not NA), indicates whether a command window should be displayed initially as a minimized window. |
invisible |
logical (not NA), indicates whether a command window should be visible on the screen. |
# NOT RUN {
# list all files in the current directory using the -F flag
# }
# NOT RUN {
system("ls -F")
# }
# NOT RUN {
# t1 is a character vector, each element giving a line of output from who
# (if the platform has who)
t1 <- try(system("who", intern = TRUE))
try(system("ls fizzlipuzzli", intern = TRUE, ignore.stderr = TRUE))
# zero-length result since file does not exist, and will give warning.
# }