• Post Reply Bookmark Topic Watch Topic
  • New Topic

Returning exit code to calling shell script  RSS feed

 
Vallabh Inamdar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have java class which is called from the shell script, like java <classname>. The java class internally do some processing and gets the error code at the end e.g. 0 if the process is successful and some -ve value if the process is unsussessful. I want to return this error code to the calling shell script.
currently we have put a single System.out.println(iErrorCode); statement in the class and shell script reads this value to get the error code. We tried using the System.exit(iErrorCode), but that didn;t return the iErrorCode correctly everytime.
It will be great if some one helps me out of this problem
thanks and regards
vallabh
 
Corneil du Plessis
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the function java.lang.System.exit(int), the exit code will be set to whatever you pass to the function.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!