/* REXX */ /* */ /* AUTHOR: Mark Zelden */ /* */ /* Trace ?r */ /*********************************************************************/ /* JOBCHECK */ /* */ /* This program will check if a task (STC,TSU, OR JOB) */ /* is active in the system. */ /* */ /* The program must be passed a parm of the task name to check. */ /* */ /* If the task is found the condition code is set to 0. */ /* If the task is not found the condition code is set to 4. */ /* */ /* Normal completion messages: */ /* JOBCHECK - XXXXXXXX WAS ACTIVE IN THE SYSTEM - CONDITION */ /* CODE SET TO 00 */ /* JOBCHECK - XXXXXXXX WAS NOT ACTIVE IN THE SYSTEM - CONDITION */ /* CODE SET TO 04 */ /* */ /* Abnormal completion messages: */ /* JOBCHECK - NO PARM VALUE ENTERED - CONDITION CODE SET TO 16 */ /* JOBCHECK - BAD PARM - MAXIMUM TASKNAME LENGTH IS 8 CHARACTERS - */ /* CONDITION CODE SET TO 16 */ /* */ /*********************************************************************/ /* Sample batch execution JCL: */ /* */ /* //MYJOB JOB (ACCT),CLASS=A,MSGCLASS=H */ /* //JOBCHECK EXEC PGM=IRXJCL,PARM='JOBCHECK MYJOB' */ /* //SYSTSIN DD DUMMY */ /* //SYSTSPRT DD SYSOUT=* */ /* //SYSEXEC DD DSN=your.rexx.sysexec.lib,DISP=SHR */ /* */ /*********************************************************************/ Arg TASKPRM If TASKPRM = '' then do Say 'NO PARM VALUE ENTERED - CONDITION CODE SET TO 16' Exit 16 End If Length(TASKPRM) > 8 then do Say 'BAD PARM - MAXIMUM TASKNAME LENGTH IS 8 CHARACTERS -' , 'CONDITION CODE SET TO 16' Exit 16 End /*********************************************************************/ Numeric digits 10 /* dflt of 9 not enough */ /*********************************************************************/ /* Point to ASVT */ /*********************************************************************/ CVT = C2d(Storage(10,4)) /* point to CVT */ CVTASVT = C2d(Storage(D2x(CVT+556),4)) /* point to ASVT */ ASVTMAXU = C2d(Storage(D2x(CVTASVT+516),4)) /* max number of entries */ /*********************************************************************/ /* This routine checks each ASVT entry. */ /* If the high order bit is on, the entry is the address of the */ /* next available asid (or the last entry if zeros). */ /* If the high order bit is not on, the entry is the address */ /* of the ascb for that entry. */ /*********************************************************************/ FOUND = 'N' /* init "FOUND" flag to "N" */ Do I = 0 to ASVTMAXU-1 /* start at 0 so I*4 bumps to next entry */ ASVTENTY = Storage(D2x(CVTASVT+528+(I*4)),4) /* cur ASVT entry*/ If Bitand(ASVTENTY,'80000000'x) == '80000000'x then iterate /*********************************************************************/ /* We have a valid ASCB address - check it */ /*********************************************************************/ Else do ASVTENTY = C2d(ASVTENTY) /* change to decimal for code below */ ASCBJBN = C2d(Storage(D2x(ASVTENTY+172),4)) /* ASCBJBNI */ If ASCBJBN = 0 then , /* not a job - must be START/LOGON/MOUNT */ ASCBJBN = C2d(Storage(D2x(ASVTENTY+176),4)) /* ASCBJBNS */ TASKNAME = Strip(Storage(D2x(ASCBJBN),8)) /* point to name */ If TASKNAME == TASKPRM then do FOUND = 'Y' /* set found flag */ Leave I /* leave loop, no need to continue */ End End /* Else do */ End /* Do I */ /*********************************************************************/ /* Done processing - write end messages and set return code */ /*********************************************************************/ If FOUND = 'Y' then do Say 'JOBCHECK -' TASKPRM 'WAS ACTIVE IN THE SYSTEM -' , 'CONDITION CODE SET TO 00' Exit 0 End Else do Say 'JOBCHECK -' TASKPRM 'WAS NOT ACTIVE IN THE SYSTEM -' , 'CONDITION CODE SET TO 04' Exit 4 End