繁体   English   中英

将 stdout = TRUE 添加到 R 的 system2 命令并接收警告。 为什么?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM