Reputation: 574
in windows, would like to capture java pid using R system() like the following:
system("java -jar .\app.jar john_doe 1600_50_555", wait = FALSE)
have tried:
grep("^java.exe",readLines(textConnection(system('tasklist',intern=TRUE))),value=TRUE)
would like to capture that pid without using grep() or additional filtering.
Upvotes: 2
Views: 169
Reputation: 36676
You can use ps
package for that.
library(ps)
library(dplyr)
system("java -jar .\app.jar john_doe 1600_50_555", wait = FALSE)
pid <- ps() %>%
filter(name == "java.exe") %>%
pull(pid)
Upvotes: 2