File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes return code from a java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "return code from a java program " Watch "return code from a java program " New topic
Author

return code from a java program

Maalti Iyer
Ranch Hand

Joined: Jul 11, 2001
Posts: 52
Hi,

I've a Unix shell script that calls multiple (4) java programs. It should call a java program in the sequence only if the provious program was successful.(ie program 2 should be called only if program 1 was successful).

can someone help me?

Thanks
Maalti.
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Use System.exit() in your Java programs to return an error level to the UNIX shell.


Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
To add to what Tom said, in Unix it is traditional to exit with a zero to indicate success. Any other value indicates some sort of error occured. In some programs the exit value tells you which error occured.


<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Originally posted by Tom Blough:
Use System.exit() in your Java programs to return an error level to the UNIX shell.


If you do System.exit(-1);, it will kill your App Server
[ October 28, 2005: Message edited by: Chetan Parekh ]

My blood is tested +ve for Java.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

After implementing the 'System.exit (status);' -stuff, you combine the commands like this:


to execute P2 only if P1 succeeded, and so on.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return code from a java program