I am using below command to execute a shell script from java. I also need to check if script execution is successful without any errors. Is there any possible method to do this? Please advise.
ProcessBuilder pb = new ProcessBuilder("test.sh", arg1, arg2);
Process p = pb.start();
You need to check if the process terminated which you can do with
Process.waitFor() which blocks until the process completed. The return value of this call is the return code of the system command you invoked.