aspose file tools*
The moose likes Java in General and the fly likes how to retrieve the value of ps - A command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to retrieve the value of ps - A command " Watch "how to retrieve the value of ps - A command " New topic
Author

how to retrieve the value of ps - A command

baran tamer
Ranch Hand

Joined: Jan 22, 2009
Posts: 33
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

Joined: Dec 24, 2008
Posts: 28
Is it works with only:
String commandToBeExecuted = "ps -A";
?
Dmitry Mamonov
Greenhorn

Joined: Dec 24, 2008
Posts: 28


Code above works fine. May be grep command eliminates all rows?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

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.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

"ps - A | grep vlc" is not one command - it's two commands, with the output of the first used as input for the second.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to retrieve the value of ps - A command