The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to get the exit status yhacks Shell Programming and Scripting 1 05-19-2008 08:06 AM
Running Shell Script from Java Asty Shell Programming and Scripting 3 08-14-2006 09:08 AM
checking exit status of a shell script kdipankar Shell Programming and Scripting 2 05-09-2006 01:08 AM
exit unix, but says running jobs yls177 UNIX for Dummies Questions & Answers 6 10-25-2002 03:08 AM
How to find the exit status of last command in Unix? rajugp1 High Level Programming 1 09-10-2002 11:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-02-2007
mmcds mmcds is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 1
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.

java.io.FileNotFoundException error
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:129),

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.

notifycode=$?
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 (permalink)  
Old 08-02-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 08-02-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by mmcds View Post
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.

Code:
static void java.lang.System.exit(int status);
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0