Operating System - OpenVMS
1828244 Members
2650 Online
109975 Solutions
New Discussion

Exiting with error / success codes to VMS Scheduler...

 
Atul Chojar
New Member

Exiting with error / success codes to VMS Scheduler...

In your experience, which one of the following commands is the best one to use for exiting from a VMS DCL com script,
that is run through VMS scheduler on production servers?

$exit $SEVERITY
$exit $STATUS
$exit ($SEVERITY)
$exit ($STATUS)
13 REPLIES 13
Ian Miller.
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

If you do
$ EXIT
then the current value of $STATUS is used.
If you specify a value then it updates $STATUS with the value you give.
____________________
Purely Personal Opinion
Uwe Zessin
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

If we are talking about batch jobs:
$ exit $STATUS

or something similar. That will make sure that the true condition code is reported in the accounting file.

If you use
$ exit $SEVERITY

you are trying to turn the severity bits into a condition code - that will not work and produce invalid codes.

$ exit %x2c
%SYSTEM-F-ABORT, abort
$ show symbol $status
$STATUS == "%X0000002C"
$ show symbol $severity
$SEVERITY == "4"
$ exit $status
%SYSTEM-F-ABORT, abort
$ exit $severity
%NONAME-F-NOMSG, Message number 00000004
$
.
Jan van den Ende
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

Atul,

Welcome to the VMS Forum!.

My personal choice would be

$ exit '$status'

Meaning: exit with the VALUE of $status.
This will directly generate the associated message, if it exists and is numeric even.

$severity contains the lower 3 bits of $status, which would result in only "%NOMSG-W-No message", "%NOMSG-E-No nessage" or %NOMSG-F-No message", depending on the seroiusness of the final status. It would prevent potentially interesting and/or informative messages being displayed!

hth,

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Ian Miller.
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

The difference between
$ exit '$status'
and
$exit

is the former displays the message. The same value is returned in both cases.
____________________
Purely Personal Opinion
Mike Reznak
Trusted Contributor

Re: Exiting with error / success codes to VMS Scheduler...

Hi,

take a look in OpenVMS help

$ HELP EXIT

Very well described there ;o)

Mike
...and I think to myself, what a wonderful world ;o)
Wim Van den Wyngaert
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

1) Don't forget to put your queues "retained=error". This way you get an error entry when the job is not successful.
2) if you do exit after a delete that failed the job will fail because of a warning. So exit 1 after deletes (if noon is set, otherwise the job will abort)
3) often forgotten : subroutines require their own error handling. Default is on error then exit.

Wim
Wim
Richard Apthorp
Advisor

Re: Exiting with error / success codes to VMS Scheduler...

Coincidently I was working on something similar so I hope you don't mind if I add a further question:

I am using lib$spawn to run a command file from a program and use exit(44) for abort if it fails.
However when I then use lib$get_symbol on $STATUS I always get the same answer of %X'10000001'

How should I be doing this? Thanks.
Mike Reznak
Trusted Contributor

Re: Exiting with error / success codes to VMS Scheduler...

To Richard:

No problem to reply, but I'm not sure, tou'll be able to assign any points to answers to your question.

In DCL, if you use ON ERROR THEN EXIT, ON WARNING.... statements, then you get the right $STATUS value. When you redirect processing to some error handling inside the procedure, you have to save ZSTATUS = $STATUS value immediately after the command execution. The $STATUS value is changing after every command executed.

Mike
...and I think to myself, what a wonderful world ;o)
Uwe Zessin
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

LIB$GET_SYMBOL() translates the $STATUS symbol from your current process, not the subprocess. Your current image is still active, so $STATUS is not updated.

I haven't read up the details, but I think you want to take a look at the 'completion-status-address' argument of LIB$SPAWN().
.
Richard Apthorp
Advisor

Re: Exiting with error / success codes to VMS Scheduler...

the main program waits until lib$spawn completes. Do you mean symbols are lost from this sub_process. The return from lib$spawn is always 1 whatever the exit status of the comman d file spawned.
What would you recommend is the best way of passing back a return value from a command file spawned from a program, Thanks again.
Uwe Zessin
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

Symbols are not shared between processes. The return status from LIB$SPAWN tells whether the SPAWN was successful.

Again, I think you want to take a look at the 'completion-status-address' argument of LIB$SPAWN(). I can't check it right now, but I think it contains the subprocess' final status (i.e. what you specify with "$ exit n").
.
Ian Miller.
Honored Contributor

Re: Exiting with error / success codes to VMS Scheduler...

From the help for LIB$SPAWN

"The completion-status-address argument contains the address of the status. The system writes the value of the final completion status of the subprocess into completion-status-address when the subprocess completes. If the subprocess returns a status code of 0, the system writes SS$_NORMAL into this address."

So if you wait for the process to complete then this will contain the status you want.
____________________
Purely Personal Opinion
Richard Apthorp
Advisor

Re: Exiting with error / success codes to VMS Scheduler...

Thanks thats what I need - Sorry I don't seem to able to assign any points - I guess because I did not start it. Perhaps another button could be added to allow for additional questions...