Tuesday, June 17, 2008

Java parse system command

Here is how you can parse a system command in java.


Process p = Runtime.getRuntime().exec("/usr/local/lsf/bin/bhosts -w " + hostGroup);

BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null )
{
//Do what you want here...
}

No comments: