I need to execute ksh script from java, where I want to exit with error and provide error message.
exit 1 - exits with error code 1
But what should I do in script in order to catch the error message with getErrorStream?
proc = Runtime.getRuntime().exec(SCRIPT_PATH);
int exitV = proc.waitFor();
if(exitV !=0){
InputStream iputStream= proc.getErrorStream();
BufferedReader iput = new BufferedReader(new InputStreamReader(iputStream));
while ((line = iput.readLine()) != null){
msg.append(line);
}
}