option nolist parm _DEV = "" parm _GOAL = 'AVAIL' parm _LIMIT = 1 parm _SECONDS = 5 parm _VOLUME = ' ' IF BOUND (DEV_ERRORS) OR BOUND (DEV_OK) DELETEVAR DEV_@ ENDIF FILE DEVSTATT = DEVSTATT, OLDTEMP IF FINFO ('*DEVSTATT','EXISTS') PURGE DEVSTATT, TEMP ENDIF SETVAR DEV_ERRORS 0 SETVAR DEV_OK FALSE SETVAR DEV_VALID FALSE IF '!_DEV' = "" SETVAR DEV_ERRORS DEV_ERRORS + 1 ECHO Parm-1 is required. Ldev# (best) or device-class to & check. ENDIF IF NOT NUMERIC ('!_LIMIT') SETVAR DEV_ERRORS DEV_ERRORS + 1 ECHO Parm-3 can only be digits (it is optional max # of times & to check the device). ENDIF IF NOT NUMERIC ('!_SECONDS') SETVAR DEV_ERRORS DEV_ERRORS + 1 ECHO Parm-4 can only be digits (optional seconds to & pause between multiple checks). ENDIF IF POS ( LFT ('|' + UPS('!_VOLUME') + ' ', 7), & '| |LOUD |QUIET ') = 0 THEN SETVAR DEV_ERRORS DEV_ERRORS + 1 ECHO Parm-5, if entered, can only be 'LOUD' or 'QUIET'. ENDIF IF DEV_ERRORS > 0 SETVAR DEV_CONTINUE FALSE SETVAR DEV_STATUS "*ERROR*" IF ( HPINTERACTIVE ) OR ( UPS('!_VOLUME') = 'LOUD' ) ECHO !HPFILE inputs: ECHO 1: LDEV# or device-class(required). For a class, & shows the highest ldev#. ECHO 2: Status to wait for (default = 'AVAIL'). ECHO 3: # of times to check (default = 1). 0 or 1 & mean one pass with no pause. ECHO 4: # of seconds to pause between tries & (default = 5). '0' is permitted. ECHO 5: 'volume' controls :echoes of status messages ECHO ' ' Show final status only (default) ECHO 'QUIET' No messages ECHO 'LOUD' Messages before each pause, and at end. ECHO Output: ECHO DEV_STATUS variable - Ldev status when we are done, & or '*INVALID*'. ECHO DEV_VALID variable - true if the ldev exists. ECHO DEV_OK variable - true if exists at start & has & desired status at end. # ECHO DEV_NUM Ldev# of the device. May matter & # if requested a device-class. ECHO Other DEV_@ variables for ownership, errors, etc., & from SHOWDEV & JINFO. ECHO Byproducts: ECHO DEVSTATT temp file, JUNK variable. ECHO Requires SM capability to inquire on session devices. ECHO Sets status variables on 1 ldev or waits for it to & have the requested status. ENDIF RETURN ENDIF BUILD DEVSTATT; CIR; REC=,,F,ASCII; DISC=1; TEMP SETVAR DEV_LOOP_CNT 0 SETVAR DEV_CONTINUE TRUE WHILE DEV_CONTINUE DO SETVAR DEV_LOOP_CNT DEV_LOOP_CNT + 1 IF DEV_LOOP_CNT >= !_LIMIT SETVAR DEV_CONTINUE FALSE ENDIF IF CIERROR = 1581 SETJCW CIERROR 0 ENDIF CONTINUE SHOWDEV !_DEV > *DEVSTATT IF CIERROR = 1581 OR FINFO('*DEVSTATT','EOF') = 0 SETVAR DEV_STATUS '*INVALID*' SETVAR DEV_CONTINUE FALSE SETVAR DEV_VALID FALSE IF (DEV_LOOP_CNT = 1) SETVAR DEV_ERRORS DEV_ERRORS + 1 ELSEIF (UPS ('!_GOAL') = '*INVALID*') SETVAR DEV_OK TRUE ENDIF ELSE INPUT DEV_RECORD < *DEVSTATT SETVAR DEV_RECORD LFT (DEV_RECORD, 80) SETVAR DEV_STATUS WORD (STR (DEV_RECORD,11,15)) SETVAR DEV_VALID TRUE IF DEV_STATUS = UPS ('!_GOAL') SETVAR DEV_CONTINUE FALSE SETVAR DEV_OK TRUE ENDIF ENDIF IF DEV_CONTINUE IF UPS('!_VOLUME') = 'LOUD' ECHO LDEV![RHT(' !_DEV',8)] & Status=![LFT('!DEV_STATUS ',12)] & after![RHT(' !DEV_LOOP_CNT',4)] passes & Continue-flag=![LFT('!DEV_CONTINUE ',5)] ENDIF PAUSE !_SECONDS ENDIF ENDWHILE SETVAR DEV_JOB_ID "" SETVAR DEV_OWNER_FILES 0 SETVAR DEV_SESSION_IPADDR "" IF DEV_VALID SETVAR DEV_NUM WORD (DEV_RECORD) SETVAR DEV_OWNER RTRIM (STR (DEV_RECORD,25,18)) SETVAR DEV_SPOOLED_OUT LFT (DEV_OWNER,11) = "SPOOLER OUT" SETVAR JUNK STR (DEV_RECORD, 9, 1) SETVAR DEV_ACCEPTS_JOBS (JUNK='J') OR (JUNK='A') SETVAR DEV_ACCEPTS_DATA (JUNK='D') OR (JUNK='A') SETVAR DEV_WRITE_ENABLED STR (DEV_RECORD,20,3) = '(W)' SETVAR DEV_DOWN_PENDING POS('; DP',RHT(DEV_RECORD,-25)) > 0 IF LFT(DEV_OWNER,1) = "#" SETVAR DEV_JOB_ID WORD(DEV_OWNER) - ':' CONTINUE SETVAR DEV_SESSION_IPADDR JINFO (DEV_JOB_ID,'IPADDR') IF WORD (DEV_OWNER,,3) - ';' = 'FILES' SETVAR DEV_OWNER_FILES ![WORD (DEV_OWNER,,2)] ENDIF ENDIF ELSE SETVAR DEV_OWNER "" SETVAR DEV_NUM 0 SETVAR DEV_ACCEPTS_JOBS FALSE SETVAR DEV_ACCEPTS_DATA FALSE SETVAR DEV_WRITE_ENABLED FALSE SETVAR DEV_SPOOLED_OUT FALSE SETVAR DEV_DOWN_PENDING FALSE ENDIF IF UPS('!_VOLUME') <> 'QUIET' ECHO LDEV![RHT(' !_DEV',8)] & Status=![LFT('!DEV_STATUS ',12)] & after![RHT(' !DEV_LOOP_CNT',4)] passes & OK-flag=![LFT('!DEV_OK ',5)] & (done) ENDIF RETURN # 'DEVWAIT' command-file return some status info on a device # and/or wait for it to have a requested status. # Orig version 11/21/2003, Dave Powell, MMfab. # # Tested on MPE 7.5 (only). Requires recent # version of MPE with JINFO function. # # Best with SM capability. # # This poor sucker was started after device info was # requested on an enhancement ballot, and was finished # enough to announce to the world on the same day as HP # announced they were going to do a devinfo function. # Its original purpose was to be the backup plan if HP # didn't. # # - If you just want it to set variables for device info, # omit all but the 1st parm. Example: # :devwait 6 # :showvar dev@ # # - For an immediate answer with no pauses, omit the # 3rd parm ('_LIMIT') or pass it '1'. In that case, # 4th parm ('_SECONDS') does not matter. Example: # 'devwait 6 SPOOLED 1 999' = 'devwait 6 SPOOLED' # # - Max seconds to wait is ( _LIMIT - 1) * _SECONDS. # # - If you think a device might become UNAVAIL, then # AVAIL, and you are afraid you might catch it before # it becomes UNAVAIL, try something like this: # :DEVWAIT 7 UNAVAIL 5 1 # :DEVWAIT 7 AVAIL 50 5 # # - It counts as an error to ask about a device that does # not exist at the start, but not to ask about a network # session terminal ldev that disappears between checks # if the session logs off. # Example: DEVWAIT 34 *INVALID* 200 5 LOUD # # - To verify that a tape drive is ready for a backup, check # that 'DEV_WRITE_ENABLED' is true and status is AVAIL. # # ---------------------------------------------- # # Details on some variables: # # DEV_VALID Indicates that the device exists at the end. # - If making multiple passes on a network session # device, it may start TRUE and then become FALSE # if the session logs off. # - Many other variables are set only if this is # TRUE at the end. # # DEV_STATUS SPOOLED, DOWN, DISC, AVAIL, UNAVAIL, etc. # - Normally the 1st word of SHOWDEV's AVAIL # column; '*INVALID*' for a device that does # not exist; '*ERROR*' for calling syntax errors. # - For a network session device, may change # between passes from 'UNAVAIL' to '*INVALID*'. # Can use this to wait for a network session to # log off. # # DEV_OK True if the device exists at the start and # has the desired status at the end. # - If request '*INVALID*' and multiple checks on # a network sesssion device, and it logs off in # time, this can actually end up TRUE with # DEV_VALID false. # # DEV_WRITE_ENABLED Indicates that a tape drive is on-line # and ready to write to. # - Just having a write-enabled tape in the # drive does not set this value, it has to be # on-line. # - May not work on older versions of MPE; # it depends on '(W)' in a certain spot # in SHOWDEV's output, which works for # MPE 7.5, but the 1996 manual says it # would be just 'W', and implies a # different location. # # DEV_JOB_ID From SHOWDEV's ownership column. #Snnn # format. Filled in for session devices and # for non-spooled printers being written to # 'hot', etc. # - Not tested for other types of device ownership. # - Empty string if SHOWDEV owner field does not # start with '#'. # # DEV_SESSION_IPADDR For network session devices, the IP addr # in dotted format. Empty string for other # devices, including network printers. # # DEV_NUM Ldev# that was checked on, in case we requested # a device class. # # ------------------------------------------------ # # Notes & gotchas: # A: Showdev on non-existent device gives cierror 1581. # After this error, a successful SHOWDEV does NOT # set cierror back. # # B: Results are valid for individual device numbers # or device classes with only one member. Asking # for status of 'disc' gives the status of the # highest-numbered disc. # # C: Printer status / availability / ownership: # - Status 'SPOOLER' + ouwership blank may mean # "SPOOLER n; STOP; OPENQ" # - Ownership 'SPOOLER OUT' is the indicator that the # spooler can actually print to it. # - Status 'AVAIL' may mean a 'SPOOLER n; STOP' and # printing would be 'hot'. # # ---------------------------------------------- # # Still to do: # - Capture more JINFO items for session devices, such as # logon user & acct. # # ? Check for '(W)' indicating writeable tape with pmatch # or pos, instead of just checking bytes 20/22. # maybe if pmatch ('@(W)@', DEV_RECORD) # or if pos ('(W)', DEV_RECORD) > 0 # # ? Protect against session# & #-of-files being so high that # the word 'FILES' gets pushed out of the normal # ownership columns. # # ? Smoother handling of the jinfo security error on # ip# without SM capability. # # ? Bullet-proof the JINFO calls so we don't die if the # session that owns the device logs off at the wrong # split second ??? (what are the odds?) # # ? Special status if the device is 3000 :) # ? Wait till 2007 if the device is HP3000 and requested # status is 'UNSUPPORTED' :( # # ? Set CIERROR back to its original value, esp if > 1581? # # ? Test on other versions of MPE besides 7.5 ? # # ? Set variables for: # ? association ? # ? tape labels ? # ? etc # # ---------------------------------------------- # # Maintenance: # # 04/01/2004 - Make 1 the default _LIMIT, to make it easier # to get an immediate answer. # - Add output variables for device ownership # & ldev# # # 05/17/2004 - Setting owner's job-id & #-of-files # - Unshifting volume & goal # - Vars for job-accepting & data-accepting. # # 05/26/2004 - Boolean DEV_SPOOLED_OUT, true only if # ownership is 'SPOOLER OUT' # - DEV_SESSION_IPADDR for network sessions, # empty string for other devices. # (this reqires SM capability) # - Separate messages for each type of input error. # - Boolean DEV_DOWN_PENDING, caused by a 'DOWN' # command that has not completed. True if # '; DP' is found past position 25 of the # showdev record. Assumes that the ownership # column will never be just 'DP' because the # DOWN would have completed if the device wasn't # owned by something. # Note: other ownership info can push the # '; DP' out of the normal ownership columns into # the 'volid' area, so we can't just check the # ownership variable for the '; DP'. Example: # ' 127 J UNAVAIL #S1591: 24 FILES; DP'