Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need help in Runtime.exec() command

807599Dec 5 2006 — edited Dec 6 2006
I like to execute this command in java as below, but it seems doesn't work as expected...
Anybody knows how it works?

String cmd = "netstat -a | grep 8555 | grep ESTABLISHED | wc -l";
Process p = Runtime.getRuntime().exec(cmd);

The program was running unix env for this cmd to execute.

However, it looked like only the first part "netstat -a" got executed and the rest after | is ignored...

Is that the limitation of Process in java (not seeing the rest of cmd...)?
thanks in advance for any help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 3 2007
Added on Dec 5 2006
4 comments
334 views