Visit Our UNIX and Linux User Community

exit status running java classpath in unix shell

Thread Tools Search this Thread
Top Forums Programming exit status running java classpath in unix shell
# 1  
Old 08-02-2007
exit status running java classpath in unix shell

I have a java classpath running inside of a unix shell script. During my testing it will error with lines that show an example like this below. error
at Method)

which I know why I get that error, but when I set in my unix shell script this to see the right exit status of success/fail, it always shows a 0 for success when that isn't really the case. Below is the two lines I have set to capture the exit status and just display that exit status for now.

echo $notifycode

I have these 2 lines above on a line right below my java command in my unix shell script. How can I get my unix shell script to capture any error exit status during my shell script?
# 2  
Old 08-02-2007
Your problem doesn't have anything to do with the shell's error handling/reporting. If your java command will exit(0) even on a failure, then that's what the script will report. You need to check and confirm that your java command is exiting with the correct error code on failure.
# 3  
Old 08-02-2007
Originally Posted by mmcds
How can I get my unix shell script to capture any error exit status during my shell script?
If java throws and exception, does a stack trace then exits with an exit code of zero, then the exit code is zero.

To return an exit code you would need to call the following in the exception handler.

static void java.lang.System.exit(int status);

Previous Thread | Next Thread
Test Your Knowledge in Computers #934
Difficulty: Medium
The C standard library does not specify any specific resolution, epoch, range, or datatype for system time values.
True or False?

10 More Discussions You Might Find Interesting

1. Red Hat

Process not running: /opt/java15/jdk/bin/java -classpath /opt/apache/apache-ant-1.7.0-mod/lib/ant-la

Have no idea on what the below error message is: Process not running: /opt/java15/jdk/bin/java -classpath /opt/apache/apache-ant-1.7.0-mod/lib/ant-launcher.jar -buildfile build.xml dist. Any help? (3 Replies)
Discussion started by: gull05
3 Replies

2. Shell Programming and Scripting

Test with non-zero status does not exit shell

Hi there, I'm very used to use set -e to break my scripts if any command exits with a non-zero status. As a policy, I'm willingly expecting echo hello | grep a to break the script. The commands test 1 -eq $1 && echo hello exits with a non-zero status if $1 is not 1. BUT... It doesn't break... (2 Replies)
Discussion started by: chebarbudo
2 Replies

3. Shell Programming and Scripting

Weird Exit Status of shell script

I have a script named check which will read the content of a file and check wether those files exist in the current directory. If so it will have the exit status of 0, otherwise it will have 1. check script: #!/bin/bash if ; then #Check there is enough command line parameters. exit 1... (2 Replies)
Discussion started by: Ray Sun
2 Replies

4. Shell Programming and Scripting

store last command exit status in variable in shell script

Hello All My req is to store the exit status of a command in shell variable I want to check whether the file has header or not The header will contain the string DATA_ACQ_CYC_CNTL_ID So I am running the command head -1 $i | grep DATA_ACQ_CYC_CNTL_ID Now I have to check if... (6 Replies)
Discussion started by: Pratik4891
6 Replies

5. Shell Programming and Scripting

exit status from ksh script exec from java using runtime

how do i get the exit status from a ksh or perl script executed in a java program using Runtime? (1 Reply)
Discussion started by: twk
1 Replies

6. Shell Programming and Scripting

Capturing the exit status of the script running in background

Hi All, I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script. Is there a way I can capture the exit status of each individual child script after the execution is completed. (2 Replies)
Discussion started by: paragkalra
2 Replies

7. Programming

regarding classpath java

Hi, I have a below command.... $JAVA_HOME/bin/java -cp "/usr/orabase/product/10.2.0/lib:/usr/java/javajar/common/sched.jar:/usr/orabase/product/10.2.0/jdbc/lib/ojdbc14_g.jar:/usr/orabase/product/10.2.0/jdbc/lib/classes12.jar" I want to know where the Smart.class is... (1 Reply)
Discussion started by: PRKS
1 Replies

8. Shell Programming and Scripting

problem in exit status of the command in a shell script-FTP

Hi All, I have developed below script for FTP a file from unix machine to another machine. ftpToABC () { USER='xyz' PASSWD='abc' echo "open user $USER $PASSWD binary echo "put $1 abc.txt" >> /home/tmp/ftp.$$ echo "quit" >> /home/tmp/ftp.$$ ftp -ivn <... (3 Replies)
Discussion started by: RSC1985
3 Replies

9. Shell Programming and Scripting

checking exit status of a shell script

Hi, I have tried with the following code; if ;then echo "Failure." else echo "Success." fi to test the exit status of the test.ksh shell script. But whatever is the exit status of the test.ksh shell script Failure. is always printed. Please help. regards, Dipankar. (2 Replies)
Discussion started by: kdipankar
2 Replies

10. Programming

How to find the exit status of last command in Unix?

Hi, I want to find the exit status of the last executed command in C Shell. Tried $? but getting the error Variable syntax...$? does not seem to work in C shell.. is there any other command in C shell to find the exit status of last command? Thanks in advance, raju (1 Reply)
Discussion started by: rajugp1
1 Replies

Featured Tech Videos