Operating System - OpenVMS
1752796 Members
5639 Online
108789 Solutions
New Discussion юеВ

setting exit code for submit job

 
SOLVED
Go to solution
Sandeep_30
Occasional Advisor

setting exit code for submit job

I use sys$sndjbc to submit job and monitor them for the job completion.

JOB_COMPLETION_STATUS I recieve from sys$sndjbc (0, SJC$_SYNCHRONIZE_JOB ...) is what I use to set the status of the batch job.

One of the requirement that has come-up is that
the status of the batch job should be the exit status set inside the batch script. Where is the value of exit status stored?

Below are two example of the batch job

$! type test.com
$ show time
$ exit 0

$! type test1.com
$ show time
$ exit 1


7 REPLIES 7
Hein van den Heuvel
Honored Contributor

Re: setting exit code for submit job

RTFM.
Status codes in VMS have well defined meanings, expressed in bit-Vields.

You don't want to use 0 or 1 as status and if you do, then 1 should be succes and 0 failure (contrary to Unix). But really the lower bit alone defines succes or failure.

An other startng point to read is $HELP EXIT PARAM

hth,
Hein.
Sandeep_30
Occasional Advisor

Re: setting exit code for submit job

Hein,

Thanks for the reply. If I change the batch file to,

$! type test.com
$ show time
$ exit $STATUS

Now when I submit the above file to a batch queue using SYS$SNDJBC call. What command should I use to capture (read) the status value that exit has?
Volker Halle
Honored Contributor
Solution

Re: setting exit code for submit job

Hi,

the exit status of the job, you synchronize to, is available from the IOSB quadword parameter.

See HELP SYSTEM_SERVICES $SNDJBC

Volker.
Jan van den Ende
Honored Contributor

Re: setting exit code for submit job

Sandeep,

even simpler:

Provided you issue the SYNCHRONISE command before the batchjob finishes, the value of $STATUS after the SYNCHRONISE command will be the EXIT STATUS value of the batch job!

hth,

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Sandeep_30
Occasional Advisor

Re: setting exit code for submit job

Hi,

Thanks for the reply.

Below is part of the source, that I tried but I am still not able to get the exit value correctly. Can you please take a look and help me understand what I did wrong?

struct VMSiosb
{
int Status;
int DeviceInfo;
} IOsb;

int status;

...
...

status = sys$sndjbc (0, SJC$_SYNCHRONIZE_JOB, 0, &items, &IOsb, 0, 0);
if (status != SS$_NORMAL)
{
retstatus = status;
}

fprintf(stdout,"***DEBUG 1*** status = %d\n",status);
fprintf(stdout,"***DEBUG 1*** IOsb.status = %d\n",IOsb.Status);
fflush(stdout);

status = sys$synch (0, &IOsb);
if (status != SS$_NORMAL)
{
return(-1);
}

fprintf(stdout,"***DEBUG 2*** status = %d\n",status);
fprintf(stdout,"***DEBUG 2*** IOsb.status = %d\n",IOsb.Status);
fflush(stdout);

....
....

For exit = 1 or exit = 0 ( odd or even value), I always get the following values,

*** DEBUG 1 *** status = 1
*** DEBUG 1 *** IOsb.status = 0
*** DEBUG 2 *** status = 1
*** DEBUG 2 *** IOsb.status = 262145

Please help.

Thanks
Sandeep
Volker Halle
Honored Contributor

Re: setting exit code for submit job

Sandeep,

could you try to specify the output item code SJC$_JOB_COMPLETION_STATUS to receive the job completion status ?

The IOsb value of 262145 has the following meaning:

$ write sys$output f$message(262145)
%JBC-S-NORMAL, normal successful completion

This looks like the status of the $SNDJBC system service and NOT like the status of the job.

Volker.
Sandeep_30
Occasional Advisor

Re: setting exit code for submit job

SJC$_JOB_COMPLETION_STATUS resolved the issue.

Thanks for all the help.

Sandeep