I want to be able to make run a system command on Mac OSX from within Java. My code looks like this:
public void checkDisks() throws IOException, InterruptedException {
Process p = Runtime.getRuntime().exec("df -h");
int exitValue = p.waitFor();
System.out.println("Process exitValue:" + exitValue);
BufferedReader reader = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line = reader.readLine();
while (line != null) {
line = reader.readLine();
}
System.out.println(line);
}
This always returns null and an exitValue of 0. Never done this before in Java so any thoughts or suggestions greatly appreciated.