I have a situation where i need to execute a UNIX command from a .jar. I have tried the following ( date is arbitary):
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
java.lang.Process p = rt.exec("sudo date --set=\"Tue Aug 11 10:10:20 BST 2015\"");
p.waitFor();
logger.log("executed with value: " + p.exitValue());
I was just wondering if there is a way to check the exit code in this instance?
NB: I have executed a command this way namely "sudo mkdir -p /root/abcd" which does work.