ID EN
System & OS

system

R Base 3.6.2 🇮🇩 Bahasa Indonesia

sistem memanggil perintah OS yang ditentukan oleh perintah.

Syntax

R
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)

Arguments

Parameter Deskripsi
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.

Return Value

Jika magang = TRUE, vektor karakter memberikan keluaran perintah, satu baris per string karakter. (Baris keluaran lebih dari 8095 byte akan dipecah.) Jika perintah tidak dapat dijalankan, kesalahan R akan dihasilkan. Di bawah konsol Rgui, magang = TRUE juga menangkap stderr kecuali abaikan.stderr = TRUE. Jika perintah dijalankan tetapi memberikan status keluar bukan nol, hal ini akan dilaporkan dengan peringatan dan dalam atribut "status" hasilnya: atribut "errmsg" mungkin juga tersedia. Jika magang = SALAH, r

Details

Antarmuka ini menjadi agak rumit selama bertahun-tahun: lihat system2 untuk antarmuka yang lebih portabel dan fleksibel yang direkomendasikan untuk kode baru. perintah diurai sebagai perintah ditambah argumen yang dipisahkan oleh spasi. Jadi jika jalur ke perintah (atau argumen tunggal seperti jalur file) berisi spasi, maka harus dikutip misalnya dengan shQuote. Hanya tanda kutip ganda yang diperbolehkan di Windows: lihat contohnya. (Catatan: nama jalur Windows tidak boleh berisi tanda kutip ganda, jadi kita tidak perlu khawatir untuk keluar dari tanda kutip yang disematkan.) Perintah harus berupa file yang dapat dieksekusi (ekstensi .exe, .com) atau file batch (ekstensi .cmd dan .bat): ekstensi ini dicoba secara bergantian jika tidak ada yang disediakan. Ini berarti pengalihan, pipa, perintah internal DOS,… tidak dapat digunakan: lihat shell jika Anda ingin meneruskan perintah shell-li

Contoh

Example
R
# 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.
# }

See Also

shell or shell.exec for a less raw interface. man system and man sh for how this is implemented on the OS in use. .Platform for platform-specific variables. pipe to set up a pipe connection.