2

I am following this instructions How to get a list of current open windows/process with Java? Which work fine if I do only ps -elf.
If I try to pipe it ps -elf | grep php This will return nothing.
I did make sure I have a php process running <?php sleep('10000000'); which is found by running ps -elf | grep php directly on the command line.

The code I am using (from the other post above) and that is working unless I use pipe:

String line;
Process p = Runtime.getRuntime().exec("ps -elf");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
    System.out.print(line + "\n\n\n\n");

}
input.close();
Community
  • 1
  • 1
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278

0 Answers0