I am working on a java application that updates table in database with startdate,enddate,status of Java jobs, my requirement is to call the class java ProMon -jobStarted mocc-047 This class ProMon will insert a record into DB and return a unique id which i would like to capture in shell script run the actual job which can be a java app or a sqlloader command check the return status and update the table with the new status like this java ProMon -jobFailed $SeqNo I need to pass the SeqNo so that the correct record is updated with the new status, Please let me know how I can pass a value (long) to the calling shell script, I do not want to use System.exit to do that
For a very simple numeric only value, you can use the exit() method. IIRC, it's in java.lang.System.Runtime.
For more complex return values such as larg numbers, signed numbers, text string, and so forth, the easiest thing to do is use System.out.println() to send the data to the stdout stream, which can then be piped into another Unix command. The "read" BASH command can be used to store returned stdout.
Use of stdout for this purpose is quite common. For example: