![](/img/trans.png)
[英]How to append stderr and stdout output to file in system2 R command?
[英]Add stdout = TRUE to R's system2 command and receive warning. Why?
我需要将在 Linux (Ubuntu) 上运行的 Firefox 进程数存储在 R 脚本的变量中。 我使用的 system2 命令本身似乎有效。 但是,当我添加stdout = TRUE
以捕获字符向量中的信息时,我收到警告。 为什么会有警告?
system2(command = "ps", args = "aux | grep [f]irefox -c")
# 0
system2(command = "ps", args = "aux | grep [f]irefox -c", stdout = TRUE)
Warning message:
In system2(command = "ps", args = "aux | grep [f]irefox -c", stdout = TRUE) :
running command ''ps' aux | grep [f]irefox -c' had status 1
使用ef
而不是aux
作为ps
的参数。 根据man ps
,用于 BSD 和ef
aux
以及用于标准语法的变体。
system2('ps', '-ef | grep [f]irefox -c', stdout = TRUE)
[1] "12"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.