[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Using DCL lexicals from batch?

» close window

The Question is:

 
How can my COM file find out the name of the batch job that runs it?  We have a
 standard error program, ABORT.COM, that is called when there is an error in
 processing.  ABORT sends a VMS mail message and terminates all processing.
 All ABORT can say in it
s mail message, though, is "Check log file."  We don't know what the name of
 the log file is!  We could have had a crash in GET_DATA.COM, or in DTC.COM, or
 in any number of programs that run ABORT.  How can ABORT find out, if the
 chain of command is GET_D
ATA.COM running GET_PRICES.COM running ABORT.COM, what the chain was, and that
 the log file is GET_DATA.LOG?
 


The Answer is :

Information about any batch job can be obtained using the lexical function
F$GETQUI (or the corresponding system service SYS$GETQUI). In the specific
case of the logfile, things can be a bit tricky. If the log file was
explicitly specified with the /LOG qualifier when the job was submitted, then
the QUI item LOG_SPECIFICATION will return its name. If however it was
defaulted, the return value of LOG_SPECIFICATION will be blank. The default
log file is in the SYS$LOGIN directory of the username under which the job
was submitted using the same name as the job. Here is a sample procedure
which returns some information about the currently executing job, along with
some sample output:
 
JOBINFO.COM
$       clear = F$GETQUI("CANCEL_OPERATION",,,)
$       entry = F$GETQUI("DISPLAY_JOB","ENTRY_NUMBER",,"THIS_JOB")
$       job_parameter_p1 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_1",entry,"")
$       job_parameter_p2 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_2",entry,"")
$       job_parameter_p3 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_3",entry,"")
$       job_parameter_p4 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_4",entry,"")
$       job_parameter_p5 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_5",entry,"")
$       job_parameter_p6 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_6",entry,"")
$       job_parameter_p7 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_7",entry,"")
$       job_parameter_p8 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_8",entry,"")
$       job_name = F$GETQUI("DISPLAY_ENTRY","JOB_NAME",entry,"")
$       job_logfile = F$GETQUI("DISPLAY_ENTRY","LOG_SPECIFICATION",entry,"")
$       job_username = F$GETQUI("DISPLAY_ENTRY","USERNAME",entry,"WILDCARD")
$ count=1
$ next_file:
$   procedure_'count' = F$GETQUI("DISPLAY_FILE","FILE_SPECIFICATION",,)
$   IF procedure_'count' .EQS. "" THEN GOTO no_more_files
$   count=count+1
$ GOTO next_file
$!
$ no_more_files:
$ SHOW SYMBOL/ALL
$ EXIT
 
Sample output
$ submit/log=sys$login:logfile.log/param=("first","second") ajob, login
 
 
 
$ @SYS$LOGIN:JOBINFO
$       clear = F$GETQUI("CANCEL_OPERATION",,,)
$       entry = F$GETQUI("DISPLAY_JOB","ENTRY_NUMBER",,"THIS_JOB")
$       job_parameter_p1 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_1",entry,"")
$       job_parameter_p2 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_2",entry,"")
$       job_parameter_p3 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_3",entry,"")
$       job_parameter_p4 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_4",entry,"")
$       job_parameter_p5 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_5",entry,"")
$       job_parameter_p6 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_6",entry,"")
$       job_parameter_p7 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_7",entry,"")
$       job_parameter_p8 = F$GETQUI("DISPLAY_ENTRY","PARAMETER_8",entry,"")
$       job_name = F$GETQUI("DISPLAY_ENTRY","JOB_NAME",entry,"")
$       job_logfile = F$GETQUI("DISPLAY_ENTRY","LOG_SPECIFICATION",entry,"")
$       job_username = F$GETQUI("DISPLAY_ENTRY","USERNAME",entry,"WILDCARD")
$ count=1
$ next_file:
$   procedure_1 = F$GETQUI("DISPLAY_FILE","FILE_SPECIFICATION",,)
$   IF procedure_1 .EQS. "" THEN GOTO no_more_files
$   count=count+1
$ GOTO next_file
$ next_file:
$   procedure_2 = F$GETQUI("DISPLAY_FILE","FILE_SPECIFICATION",,)
$   IF procedure_2 .EQS. "" THEN GOTO no_more_files
$   count=count+1
$ GOTO next_file
$ next_file:
$   procedure_3 = F$GETQUI("DISPLAY_FILE","FILE_SPECIFICATION",,)
$   IF procedure_3 .EQS. "" THEN GOTO no_more_files
$ no_more_files:
$ SHOW SYMBOL/ALL
  CLEAR = ""
  COUNT = 3   Hex = 00000003  Octal = 00000000003
  ENTRY = 170   Hex = 000000AA  Octal = 00000000252
  JOB_LOGFILE = "$1$DKA100:[WIZARD]LOGFILE.LOG;"
  JOB_NAME = "AJOB"
  JOB_PARAMETER_P1 = "first"
  JOB_PARAMETER_P2 = "second"
  JOB_PARAMETER_P3 = ""
  JOB_PARAMETER_P4 = ""
  JOB_PARAMETER_P5 = ""
  JOB_PARAMETER_P6 = ""
  JOB_PARAMETER_P7 = ""
  JOB_PARAMETER_P8 = ""
  JOB_USERNAME = "WIZARD"
  P1 = ""
  P2 = ""
  P3 = ""
  P4 = ""
  P5 = ""
  P6 = ""
  P7 = ""
  P8 = ""
  PROCEDURE_1 = "_$1$DKA100:[WIZARD]AJOB.COM;1"
  PROCEDURE_2 = "_$1$DKA100:[WIZARD]LOGIN.COM;54"
  PROCEDURE_3 = ""
$ EXIT
 
  WIZARD     job terminated at 27-JUN-2000 11:57:35.87
 
  Accounting information:
  Buffered I/O count:                 60      Peak working set size:       1856
  Direct I/O count:                   29      Peak virtual size:         167584
  Page faults:                       438      Mounted volumes:                0
  Charged CPU time:        0 00:00:00.04      Elapsed time:       0 00:00:00.32
 
 
  See the DCL Dictionary or HELP LEXICAL under F$GETQUI and/or System Services
  Reference Manual SYS$GETQUI(W) for details of all the item codes available
  (there are lots!).

answer written or last revised on ( 26-JUN-2000 )

» close window