• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

return code from a java program

 
Maalti Iyer
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use System.exit() in your Java programs to return an error level to the UNIX shell.
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After implementing the 'System.exit (status);' -stuff, you combine the commands like this:


to execute P2 only if P1 succeeded, and so on.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic