how to find out if a java program called inside a shell script throws an exception
Hi all,
I have a java program (not developed by me) that is being called in a shell script. I need to modify the shell script to catch if the java program throws an exception. Unfortunately the exit status of the step where the java program is being executed is always zero whether the java program works fine or throws an error. Thanks, Auth0r_Unkn0wn |
inside java you should handle exceptions and set a return code. When java exits this return code can be passed to the caller script. If this java app did not handle exceptions you will never get a different exit code.
|
I agree with pan64: the place where you should manage exceptions is inside the program, not using bash.
Given this, I think you can detect whether an exception occurred during program execution if you search for the word "Exception" in stderr output: Code:
TEMPFILE=`mktemp` |
All times are GMT -5. The time now is 04:21 PM. |