This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Resilient Oracle PL/SQL: Building Resilient Database Solutions for Continuous Operation and have Stephen Morris on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst
  • Peter Rooke
  • Mikalai Zaikin
Bartenders:
  • Himai Minh

return code from a java program

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use System.exit() in your Java programs to return an error level to the UNIX shell.
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic