Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

OpenVMS DCL Error Handling

 
SOLVED
Go to solution

OpenVMS DCL Error Handling

Hi
I'm "very" new to OpenVMS. I have a number od DCL scripts that do backups and copies etc. We also employ an SNMP based agent that provides a user trap facility based on a command procedure. All I need to pass this procedure is a single parameter. eg.
$ @send_severity_trap "%SYSTEM-F-NOLOGNAM, no logical name match".
This prcedure tests for the severity and then writes to a mailbox.
My question is simply, what is the simplest way to implement this? At the top of my script should I set error handling at a specific desired minimum severity eg. ON ERROR THEN GOTO ERR1
Then at ERR1: what should I pass to the procedure send_severity_trap.com?
Regards
Graham
15 REPLIES
Robert Gezelter
Honored Contributor

Re: OpenVMS DCL Error Handling

Graham,

You can use ON ERROR (and its related commands, ON WARNING, ON SEVERE_ERROR) to trap these conditions.

However, it may not be optimal. The problem is that DCL does not report WHERE or WHAT generated the error. For reporting that a problem occurred, it may be adequate. For troubleshooting, the results are limited.

This also presumes that your script does not invoke other scripts.

- Bob Gezelter, http://www.rlgsc.com
Wim Van den Wyngaert
Honored Contributor

Re: OpenVMS DCL Error Handling

Place your error routine in the beginning of the dcl script. Otherwise a missing " in the script will cause DCL to not find the routine.

$Abort:
$ stat=$status
$ reason=f$mes(status) + "(''status')"
$ @send "''reason'"


Wim
Wim
Wim Van den Wyngaert
Honored Contributor

Re: OpenVMS DCL Error Handling

Also :

The on error is reset when it is executed (reset means back to on error then exit".

Subroutines and files executed via @ also require "on error" or will have the default.

If set noon is used, make sure set on is done again in all cases. Otherwise the error will be ignored.

In big scripts, I regularly set the symbol "place" to a value and display it in the abort routine. Makes it easier to debug.

Wim
Wim
comarow
Trusted Contributor

Re: OpenVMS DCL Error Handling

Since you are new to VMS, as a more general answer, try to get the book, "Writing Real Programs in DCL". It will includes examples of error handling, as well as many other examples and techniques you will likely need.

As someone new to VMS, it sounds like you are doing great. Welcome!
Ian Miller.
Honored Contributor

Re: OpenVMS DCL Error Handling

Lots of dcl examples can be found at dcl.openvms.org

Details on the book are at
http://www.amazon.com/exec/obidos/external-search?search-type=ss&tag=tru64org&keyword=DCL&index=books

See also DCL Dialogue Online
http://www.kgb.com/dcl.html

____________________
Purely Personal Opinion
Wim Van den Wyngaert
Honored Contributor

Re: OpenVMS DCL Error Handling

Also bis :

Use dcl_check (freeware) to verify if the syntax is (probaly) correct. E.g. goto labels that don't exists are verified.

Wim
Wim

Re: OpenVMS DCL Error Handling

Thanks for the help so far.
I seem to have something working. The majority of scripts are returning fine ...
(Successful. %SYSTEM-S-NORMAL, normal successful completion ). These scripts usually only do copies etc. The client wants this -S- severity reported since NNM must show green in the "VMS Jobs" alarm category unless there is a failed or problematic job.
However when an Oracle hotbackup script runs it returns the following:
(Warning. %BACKUP-W-NOMSG, Message number 10A38410 ) My question is, how do I now interpret the Message Number?
My call is as follows:
@send_severity_trap.com "''F$MESSAGE($status)' : Msg source = ec_db_hotbkup_pm.com"
Regards
Graham
Robert Atkinson
Respected Contributor
Solution

Re: OpenVMS DCL Error Handling

Graham,
messages for BACKUP are stored in a different file, SYSMGTMSG.EXE :-

ALPHA_ROB$ SET MESSAGE SYS$MESSAGE:SYSMGTMSG.EXE
ALPHA_ROB$ ws f$mess("%X10A38410")
%BACKUP-W-ACCONFLICT, !AS is open for write by another user

Rob.

Re: OpenVMS DCL Error Handling

Thanks Rob
Yes, I would have expected that message since when Oracle is in hotbackup mode the files will be available to other users for writing.
Regards
Graham
Wim Van den Wyngaert
Honored Contributor

Re: OpenVMS DCL Error Handling

As far as I remember the files remain open for write during the hotbackup but oracle will post the buffers and hold all write operations until the backup is finished.

Note that backup has another messages too : files gone during backup.

Wim
Wim
Ian Miller.
Honored Contributor

Re: OpenVMS DCL Error Handling

A handy command file for translating error codes is at http://h71000.www7.hp.com/wizard/wiz_5171.html
____________________
Purely Personal Opinion

Re: OpenVMS DCL Error Handling

Hi again,
My send_trap.com script looks something like this:

$ percent = f$extract(0,1,p1)
$ if percent .nes. "%" then goto NO_SEV_CODE
$ sevcode = f$extract(f$locate("-",p1)+1,1,p1)
$ sevcode = f$edit(sevcode, "UPCASE")
$
$ if sevcode .eqs. "S" then goto S_SEV_CODE
$ if sevcode .eqs. "I" then goto I_SEV_CODE
$ if sevcode .eqs. "W" then goto W_SEV_CODE
$ if sevcode .eqs. "E" then goto E_SEV_CODE
$ if sevcode .eqs. "F" then goto F_SEV_CODE
$ goto NO_SEV_CODE
$
$S_SEV_CODE:
$ target = "SUCCESS_TRAP"
$ goto WRITE_MSG
$I_SEV_CODE:
$ target = "INFORMATIONAL_TRAP"
$ goto WRITE_MSG
$W_SEV_CODE:
$ target = "WARNING_TRAP"
$ goto WRITE_MSG
$E_SEV_CODE:
$ target = "ERROR_TRAP"
$ goto WRITE_MSG
$F_SEV_CODE:
$ target = "FATAL_TRAP"
$ goto WRITE_MSG
$NO_SEV_CODE:
$ target = "USER_TRAP"
$ goto WRITE_MSG
$
$WRITE_MSG:
$ open/write usr_trp_mbx 'target'
$ write usr_trp_mbx p1
$ close usr_trp_mbx
*****************************************
Now when I call this in my working scripts as follows:

$ SET VERIFY
$! SET NOON
$ ON ERROR THEN GOTO TRAP
$ (Do some work)
$ TRAP:
$ @send_trap.com "''F$MESSAGE($status)' : Msg source = ec_stm_image_copy_crb.com"

******************************************
If I write all of the output to a log file
and execute my working script I get the following result in the log:

$ SET VERIFY
$! SET NOON
$ ON ERROR THEN GOTO TRAP
$!

$!Do some work
$ copy dka500:[hcm01]*.* habs"arch"::dkc0:[hcm01]*.*
$!
$! Built in trap for error handling
$ TRAP:
$ @send_trap.com "%SYSTEM-S-NORMAL, normal successful completion"

$ percent = f$extract(0,1,p1)
$ if percent .nes. "%" then goto NO_SEV_CODE
$ sevcode = f$extract(f$locate("-",p1)+1,1,p1)
$ sevcode = f$edit(sevcode, "UPCASE")
$
$ if sevcode .eqs. "S" then goto S_SEV_CODE
$S_SEV_CODE:
$ target = "SUCCESS_TRAP"
$ goto WRITE_MSG
$WRITE_MSG:
$ open/write usr_trp_mbx SUCCESS_TRAP
%DCL-E-OPENOUT, error opening HABS"arch"::MBA140:[HCM01].DAT; as output
-RMS-F-DEV, error in device name or inappropriate device type for operation
$ TRAP:
$ @send_trap.com "%RMS-F-DEV, error in device name or inappropriate device type for operation"

$ percent = f$extract(0,1,p1)
$ if percent .nes. "%" then goto NO_SEV_CODE
$ sevcode = f$extract(f$locate("-",p1)+1,1,p1)
$ sevcode = f$edit(sevcode, "UPCASE")
$
$ if sevcode .eqs. "S" then goto S_SEV_CODE
$ if sevcode .eqs. "I" then goto I_SEV_CODE
$ if sevcode .eqs. "W" then goto W_SEV_CODE
$ if sevcode .eqs. "E" then goto E_SEV_CODE
$ if sevcode .eqs. "F" then goto F_SEV_CODE
$F_SEV_CODE:
$ target = "FATAL_TRAP"
$ goto WRITE_MSG
$WRITE_MSG:
$ open/write usr_trp_mbx FATAL_TRAP
%DCL-E-OPENOUT, error opening HABS"arch"::MBA144:[HCM01].DAT; as output
-RMS-F-DEV, error in device name or inappropriate device type for operation

****************************************
My question is why when the working script has no failures the SUCCESS trap is received by the SNMP manager, but when the script has errors as shown above, then the send_trap.com does not send these through to the SNMP manager?

If I paste the command (shown below) at the command prompt then the thing works.

@send_trap.com "%RMS-F-DEV, error in device name or inappropriate device type fo
r operation"

Regards
Graham
David B Sneddon
Honored Contributor

Re: OpenVMS DCL Error Handling

Graham,

A slightly modfied version... and a question

$ set verify
$ set noon
$ copy dka500:[hcm01]*.* habs"arch"::dkc0:[hcm01]*.*
$ copy_status = $status
$ call send_trap "''f$message(copy_status)'"
$ exitt 1
$
$send_trap: subroutine
$ ! SEND_TRAP.COM
$ the_message = P1
$ if (f$extract(0,1,the_message) .nes. "%") then goto no_sev_code
$ sevcode = f$element(1,"-",the_message)
$ sevcode = f$edit(sevcode, "UPCASE")
$ target = "USER_TRAP"
$ if sevcode .eqs. "S" then target = "SUCCESS_TRAP"
$ if sevcode .eqs. "I" then target = "INFORMATIONAL_TRAP"
$ if sevcode .eqs. "W" then target = "WARNING_TRAP"
$ if sevcode .eqs. "E" then target = "ERROR_TRAP"
$ if sevcode .eqs. "F" then target = "FATAL_TRAP"
$ open/write usr_trp_mbx 'target'
$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$!!!!!!! what exactly are you expecting the above line to do?
$ write usr_trp_mbx "''the_message'"
$ close usr_trp_mbx
$ exitt 1
$ endsubroutine

tardis_FTA7> @a.a
$ set verify
$ set noon
$ copy dka500:[hcm01]*.* habs"arch"::dkc0:[hcm01]*.*
%COPY-E-OPENIN, error opening DKA500:[HCM01]*.*; as input
-RMS-F-DEV, error in device name or inappropriate device type for operation
$ copy_status = $status
$ call send_trap "%COPY-E-OPENIN, error opening !AS as input"
$send_trap: subroutine
$ ! SEND_TRAP.COM
$ the_message = P1
$ if (f$extract(0,1,the_message) .nes. "%") then goto no_sev_code
$ sevcode = f$element(1,"-",the_message)
$ sevcode = f$edit(sevcode, "UPCASE")
$ target = "USER_TRAP"
$ if sevcode .eqs. "S" then target = "SUCCESS_TRAP"
$ if sevcode .eqs. "I" then target = "INFORMATIONAL_TRAP"
$ if sevcode .eqs. "W" then target = "WARNING_TRAP"
$ if sevcode .eqs. "E" then target = "ERROR_TRAP"
$ if sevcode .eqs. "F" then target = "FATAL_TRAP"
$ open/write usr_trp_mbx ERROR_TRAP
$!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$!!!!!!! what exactly are you expecting the above line to do?
$ write usr_trp_mbx "%COPY-E-OPENIN, error opening !AS as input"
$ close usr_trp_mbx
$ exitt 1
$ exitt 1
tardis_FTA7> dire error*

Directory DBS0:[SCRATCH]

ERROR_TRAP.DAT;5 1/18 8-MAR-2006 08:14:21.20

Total of 1 file, 1/18 blocks.
tardis_FTA7> type error_trap.dat
%COPY-E-OPENIN, error opening !AS as input
tardis_FTA7>

Dave
Wim Van den Wyngaert
Honored Contributor

Re: OpenVMS DCL Error Handling

1. You didn't place your trap in the beginning of the procedure
2. You didn't do a on error after the error that caused the 2nd trap.

Wim
Wim
Jan van den Ende
Honored Contributor

Re: OpenVMS DCL Error Handling

Graham,

In your script, when you try to open SUCCESS_TRAP, the error message tries to explain what is the problem:
"... error opening HABS"arch"::MBA140:[HCM01].DAT; ... "

Try inserting a line
$ SHOW LOGICAL SUCCESS_TRAP
just before your COPY, and you will see that the logical name SUCCESS_TRAP does exist, and has the value
HABS"arch"::MBA140:
Now, this is the specification of a mailbox device on a remote (DECnet) node...
If you try to open a file with an incomplete specification ( = device:[directory]name.extension;version ), then the file parser supplies any missing elements from the processes' current default.
And since a mailbox is not file structured, such devices do not have a dir spec.
Incluse a
$ SHOW DEFAULT
as well, and you will get [HCM01], try it!
No name is given, defaulting to empty string, and the file type defaults to .DAT
Version for OPEN/WRITE is ";", meaning the next higher or ;1 if not yet present.

And now, we are back to the mailbox not being file structured, leading to
"error in device name or inappropriate device type for operation"

...

Obviously this code is executed form a remote DECnet node.
There ARE ways to get your message written to the network mailbox, but we need some more info on the specifics of the connection to give you a working solution.

hth,

Proost.

Have one on me.

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