August 10th, 1999, 11:10 AM
Hi all,
Could someone please help me with this: I am trying to run a dos/unix command within my java application by using:
String command = "ping hostname";
try {
(Runtime.getRuntime()).exec(command);
}
catch (Exception e) {}
It works fine except for the fact that I don't know how to get the output. For instance, when I issue the command "Ping hostname", it would execute successufully, but I'd like to have the output redirected to a text file: ie:
(Runtime.getRuntime()).exec("ping > result.txt");
I thought that this method should work, but it seems that no output text file is being generated.
Any help on this would be greatly appreciated.
TN
Could someone please help me with this: I am trying to run a dos/unix command within my java application by using:
String command = "ping hostname";
try {
(Runtime.getRuntime()).exec(command);
}
catch (Exception e) {}
It works fine except for the fact that I don't know how to get the output. For instance, when I issue the command "Ping hostname", it would execute successufully, but I'd like to have the output redirected to a text file: ie:
(Runtime.getRuntime()).exec("ping > result.txt");
I thought that this method should work, but it seems that no output text file is being generated.
Any help on this would be greatly appreciated.
TN