Originally Posted by cjtemple
Here's what works with Linux (Tested with Centos 5.8, kernel 2.6.18.something, and Java 1.6.0_22):
Capture the stderr output from the process by opening a reader on the error stream.
To test this:
For my system, after modifying the "ping" command to be consistent with my version, when trying to ping with a packet size of 100000 bytes, I get
Executing "ping -c 1 -s 100000 google.com"
From stderr: Error: packet size 100000 is too large. Maximum is 65507
And there is no output from stdout (The "line" String is null.)
Also, note that System.getProperty("os.name") yields the String "Linux
" on my system, so I also had to modify your OS identification logic to get it to run.
Bottom line for all OS-dependent issues/solutions: IWFMYMMV (It Works For Me; Your Mileage May Vary.)