/**/
trace o
'@ECHO OFF'
arg input
call a_initial
if result = 0 then do
do forever
call b_check
if result <> 0 then leave
call syssleep delay
end
end
if result <> -1 then finalrc = result
else finalrc = 0
exit finalrc
a_initial:
signal on syntax
'@ECHO OFF'
call aa_nlssetup
call ab_otherinit
call ac_parameters
if result <> 0 then return result
return 0
aa_nlssetup:
esc = '1b'x'['
normal = esc'0;37;40m'
crlf = '0d'x||'0a'x
msg.1 = "WAI0001E: You are currently not logged on to any domain. command cannot be issued"
msg.2 = "WAI0002E: The domain %1 is not valid or is unavailable. Command cannot continue"
msg.3 = "WAI0003E: The alias %1 is not a valid alias, database cannot be located"
msg.4 = "WAI0004E: REXXUTIL.DLL or CHKSTDLL.DLL could not be accessed. Please ensure"||crlf
msg.4 = msg.4||"that these DLLs are in a directory specified in the LIBPATH"
drop crlf
return 0
ab_otherinit:
version = '2.12'
NewChkFile = 'CHKSTORE.DBN'
call RxFuncAdd "SysLoadFuncs" , "REXXUTIL" , "SysLoadFuncs"
call SysLoadFuncs
call RxFuncAdd "ChkStLoadFuncs" , "CHKSTDLL" , "ChkStLoadFuncs"
call ChkStLoadFuncs
do i = 1 to queued() ; pull . ; end
parse source . . thisprg .
thisprg_drive = filespec('drive',thisprg)
thisprg_path = filespec('path',thisprg)
prgpath = thisprg_drive||thisprg_path
return 0
ac_parameters:
if left(input,1) = '?' then do
call aca_help
exit 0
end
db_location = 'LOGON'
domain = ''
if pos('/DB:',input) <> 0 then do
parse var input beg '/DB:'db_location end
input = beg||end
end
if pos('/W:',input) <> 0 then do
parse var input beg '/W:'delay end
input = beg||end
end
if datatype(delay,'n') <> 1 then delay = 5
parse value ChkStNetUser() with myuserid mycomputername mydomain
if mydomain = '' then do
call x_msg '1'
return 1
end
domain = mydomain
domain_server = ChkStDCName(domain)
if pos('ERROR',domain_server) <> 0 then do
call x_msg '2' , domain
return 2
end
if left(db_location,1) <> '\' & substr(db_location,2,1) <> ':' & ,
left(db_location,1) <> '.' then do
parse value ChkStNetAlias(domain_server,db_location) with alias_server alias_path
if pos('ERROR',alias_server) <> 0 then do
call x_msg '3' , db_location
return 3
end
if strip(alias_server,'L','\') <> computername then ,
alias_drive  = alias_server'\'translate(alias_path,'$',':')
else
alias_drive = alias_path
end
else ,
alias_drive = strip(db_location,'t','\')
NewChkFile = alias_drive||'\'||NewChkFile
return 0
aca_help:
say 'CHKWAIT - version' version
say '(c) Copyright International Business Machines Corporation 1994.'
say 'All rights Reserved'
say
say 'CHKWAIT: This program just waits until there is no CHKSTORE or CHKUNREV'
say "         still running. Ideal for waiting for the CHKSTORE database"
say '         to not be locked before doing a reboot.'
say '         You must be logged on as an administrator to do run this.'
say
say 'Calling Convention'
say '------------------'
say 'CHKWAIT /W:delay /DB:database_location'
say
say 'where:-'
say '   database_location = alternative location of the chkstore database'
say '                       This is optional, the default being locate the'
say '                       database on the LOGON alias.'
say '   delay             = delay in seconds before checking again. Default'
say '                       is 5 seconds'
return 0
b_check:
if stream(NewChkFile,'c','query exists') <> '' then do
rc = stream(NewChkFile,'c','open')
if rc = 'READY:' then do
rc = stream(NewChkFile,'c','close')
return -1
end
else do
if rc = 'NOTREADY:32' then do
return 0
end
else do
return -1
end
end
end
return -1
syntax:
signal off syntax
where = SigL
say 'Syntax Error in line' where 'occured'
call x_msg '4'
exit 0
halt:
rc = stream(NewChkFile,'c','close')
exit 0
