• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to retrieve the value of ps - A command

 
baran tamer
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello , i am trying to get the pid of a process which i know is unique

My code below is not working for "ps - A | grep vlc" , however it works for "ifconfig"





output returns null . Any ideas ?
 
Dmitry Mamonov
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it works with only:
String commandToBeExecuted = "ps -A";
?
 
Dmitry Mamonov
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Code above works fine. May be grep command eliminates all rows?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

As an extra, have a read of the Javaworld article "Why Runtime.exec() won't", it's a very important set of guidelines when dealing with this sort of thing.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ps - A | grep vlc" is not one command - it's two commands, with the output of the first used as input for the second.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic