Hi every body,
I am trying to execute this commad (/usr/bin/rrdtool lastupdate my_rrdfile_path) in java by Runtime.getRuntime.exe().
executing this command in linux shell will return some status of my system. but when I execute it by java, it returns null!
here is some part of my program:
String rrdCmd = "/usr/bin/rrdtool lastupdate " + rrdPath; String temp = null; String cmdStResult = null; Process p = null; try { p = Runtime.getRuntime().exec(rrdCmd); int exitVal = p.waitFor(); System.out.println("exitVal of rrdLastUpdate is : " + exitVal); } catch (Exception e) { System.out.println("Problem in exec()"); e.printStackTrace(); }//end of try-catch try { InputStreamReader inStreamReader = new InputStreamReader(p.getInputStream()); BufferedReader stdInput = new BufferedReader(inStreamReader); while ((s = stdInput.readLine()) != null) { System.out.println(s); }//end of while } catch (Exception ex) { System.out.println("problem!"); ex.printStackTrace(); }//end of try-catch
I thought this forum is most related to my question!
sorry if my english is poor
any guidance would be appreciated
thanks a lot.