Operating System - OpenVMS
1753847 Members
8452 Online
108807 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().
.