2

I require the number of Firefox processes running on Linux (Ubuntu) be stored in a variable in an R script. By itself the system2 command I use seems to work. However, when I add stdout = TRUE to capture the info in a character vector I get a warning. Why the warning?

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
ixodid
  • 2,180
  • 1
  • 19
  • 46

1 Answers1

1

Use ef instead of aux as the argument to ps. aux for BSD and ef and variants for standard syntex, as per man ps.

system2('ps', '-ef | grep [f]irefox -c', stdout = TRUE)
[1] "12"
kangaroo_cliff
  • 6,067
  • 3
  • 29
  • 42