Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   get PID in "lsof -i: 8080" command (http://www.velocityreviews.com/forums/t750996-get-pid-in-lsof-i-8080-command.html)

ma_kiem 07-06-2011 10:41 AM

get PID in "lsof -i: 8080" command
 
I have code:
import java.io.IOException;
import java.io.InputStream;

public class ExecuteDOSCommand {
public static void main(String[] args) {
final String dosCommand = "lsof -i: 8080";
try {
final Process process = Runtime.getRuntime().exec(dosCommand);
final InputStream in = process.getInputStream();
int ch;
while((ch = in.read()) != -1) {
System.out.print((char)ch);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

It's output:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 1234 root 123 IPv6 819768 TCP *:8080 (LISTEN)

I want to get PID=1234, how do i do?:bowl::bowl::bowl::bowl:


All times are GMT. The time now is 02:44 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.