#!/bin/sh

for test in *.t ;do
  perl -w $test 1
done

s                                                                                                                                                                                                                                                                                                                                                                                                                                                                        nt .ne. cjs_saved_cnt) .and. (cjs_saved_cnt .gt. 0) then - 	cjs_config_chg = 1i# $ if jcnt .eq. 0 then goto l1_ends $!5 $!	Now find the jobs either in any of the queues ore! $!	in the given specific queue.i $! $ cnt = 1c $ l1:r $ job = jn_1 $ que = jq_1 $ if que .eqs. ""  $ then $	call find_job TIMESETTER $ find_job: subroutine $c $!- $!      In this loop flag all existing jobso $! $  temp = f$getqui("") $  qloop: H $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_donei $ goto jloop $  jloop:oF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloop  $  qloop:qH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop: F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo1 $  jname = f$getqui("display_job","job_name",,-p$         "freeze_context,all_jobs") $!  'jname'= "true"q! $ if jname .eqs. p1 then exit 1  $  goto jloop  $  jloop:oF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloop ) $  if noaccess .eqs. "" then goto qloopp1 $  jname = f$getqui("display_job","job_name",,-c$         "freeze_context,all_jobs") $!  'jname'= "true"t! $ if jname .eqs. p1 then exit 1  $  goto jloop  $  jloop:fF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopp) $  if noaccess .eqs. "" then goto qloopp1 $  jname = f$getqui("display_job","job_name",,-c$         "freeze_context,all_jobs") $!  'jname'= "true"t! $ if jname .eqs. p1 then exit 1  $  goto jloop  $  jloop:fF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopp) $  if noaccess .eqs. "" then goto qloopp $  qloop:cH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_doneo $ goto jloop $  jloop:oF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloop) $  if noaccess .eqs. "" then goto qloop  $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo $  qloop:jH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_done  $ goto jloop $  jloop:.F $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopn) $  if noaccess .eqs. "" then goto qloopo1 $  jname = f$getqui("display_job","job_name",,-p$         "freeze_context,all_jobs") $!  'jname'= "true"q! $ if jname .eqs. p1 then exit 1  $  goto jloop  $  jloop:oF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloop ) $  if noaccess .eqs. "" then goto qloopp1 $  jname = f$getqui("display_job","job_name",,-c$         "freeze_context,all_jobs") $!  'jname'= "true"t! $ if jname .eqs. p1 then exit 1  $  goto jloop  $  jloop:fF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopp) $  if noaccess .eqs. "" then goto qloopp $  qloop:cH $  qname = f$getqui("display_queue","queue_name","*","batch,wildcard")+ $  if qname .eqs. "" then goto qloop_doneo $ goto jloop $  jloop:oF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloop) $  if noaccess .eqs. "" then goto qloop 1 $  jname = f$getqui("display_job","job_name",,-p$         "freeze_context,all_jobs") $!  'jname'= "true"q! $ if jname .eqs. p1 then exit 1  $  goto jloop  $  jloop:oF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloop ) $  if noaccess .eqs. "" then goto qloopp1 $  jname = f$getqui("display_job","job_name",,-c$         "freeze_context,all_jobs") $!  'jname'= "true"t! $ if jname .eqs. p1 then exit 1  $  goto jloop  $  jloop:fF $  noaccess = f$getqui("display_job","job_inaccessible",,"all_jobs")- $  if noaccess .eqs. "true" then goto jloopp) $  if noaccess .eqs. "" then goto qloopp1 $  jname = f$getqui("display_job","job_name",,-c$         "freeze_context,all_jobs") $!  'jname'= "true"t! $ if jname .eqs. p1 then exit 1  $ else	 $ endif " $ if .not. $status then js_1 = 1 $! $ cnt = cnt + 1e! $ if cnt .lt. jcnt then goto l1e $!2 $!	Ok we have the current config and job states.= $!	check now for configuration change. If not check againsto $!	old states. $! $ l1_end:  $ if cjs_config_chgh	 $ endifo $! $!? $ if jcnt .eq. 0 .or. cjs_saved_cnt .eq. 0 then goto skip_cmpy $!> $!	Compare old status with new status and generate a message $!	if anything changed.. $! $ cnt = 1  $ l2:e $ key0 = f$fao("jn_!3ZL",cnt)s, $ read/error=l2next/key="jn_001" cjsr jrec $ oldsts = f$elem(1,";",jrec) $ oldjn  = f$elem(2,";",jrec)o $ oldjq  = f$elem(3,";",jrec)n- $ if oldjn .nes. jn_1 .or. oldjq .nes. jq_1s	 $ endifd& $ if disable_jobs then goto skip_cmp $! $ if oldsts .nes. js_1	 $ endiff $! $ l2next:j $ cnt = cnt + 1t! $ if cnt .lt. jcnt then goto l2a $!9 $!	The previous steps collected the current informationt- $!	write back the records to save the info. $!
 $ skip_cmp:Z% $ if jcnt .eq. 0 then goto skip_sav_ $ cnt = 1c $ l3:s> $ jrec = f$fao("jn_!3ZL;!ZL;!AS;!AS", cnt, js_1, jn_1, jq_1)  $ key0 = f$fao("jn_!3ZL", cnt)) $ read/error=1$ /key="jn_001" cjsr xrec  $ write/update cjsr jrec $ goto 2$  $ 2$:  $ cnt = cnt + 1 ! $ if cnt .lt. jcnt then goto l32 $!
 $ skip_sav:   $ define/nolog cjs_saved_cnt 1 $a $ exit $ call close_files $ close_files: subroutinet $ set noon4 $ if f$trnlnm("inFile") .nes. "" then close inFile6 $ if f$trnlnm("logFile") .nes. "" then close logFile6 $ if f$trnlnm("datFile") .nes. "" then close datFile $ exit $ call send_back $ send_back: subroutine * $ rename SCAN_QUEUES.TMP SCAN_QUEUES.DAT $ exit $! $ waitl0: $ wait 0:1:0 $!  $ if f$trnlnm("STOP_SCAN_QUE")	 $ endif  $ call open_filesk $ open_files: subroutine $ sts = 114 $ if f$trnlnm("inFile") .nes. "" then close inFile6 $ if f$trnlnm("logFile") .nes. "" then close logFile $!# $ if f$sear(logfilename) .eqs. ""( $ elseA $	cdt = f$elem(0," ",f$edit(f$file(logFileName, "cdt"),"trim"))h/ $	cur = f$elem(0," ",f$edit(f$time(),"trim")) $	if cur .eqs. cdt   $	then; $		open/append/share=read  logFile SCAN_QUEUES_HFD104.LOG0 $	else	 $	endif( $ 	purge/keep=2 SCAN_QUEUES_HFD104.LOG	 $ endif  $! $!! $!	Try to access the lock file.? $!	If another job has it in the cluster just leave and sleep.  $!  $ if f$trnlnm("lck") .eqs. "" 	 $ endifi $!$ $ open/read inFile SCAN_QUEUES.INI- $ if f$trnlnm("datFile") .nes. "" then exiti& $ open/write datFile SCAN_QUEUES.TMPG $ if f$search(tmpfilename) .nes. "" then purge/keep=2 SCAN_QUEUES.TMPhG $ if f$search(datfilename) .nes. "" then purge/keep=5 SCAN_QUEUES.DATe $! $ exit sts% $ if .not. $status then goto waitl0  $!& $ vfx = f$verify(f$trnlnm("prcdbg")) $ goto mainl0  $ mainl0:a $ call chk_queue_sts $ chk_queue_sts: subroutinef $ qcnt = 0 $ disable_queues = "FALSE" $ cqs_config_chg = 0- $ cqs_saved_cnt = f$trnlnm("cqs_saved_cnt").4 $ if cqs_saved_cnt .eqs. "" then cqs_saved_cnt = 0 $! $!	Read ini file $!5 $ if f$trnlnm("inFile") .nes. "" then  close inFilea$ $ open/read inFile SCAN_QUEUES.INI $! $ p0:E $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")i! $ if prec .eqs. "" then goto p0i $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")l! $ if prec .eqs. "" then goto p0c $ p0: $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")d! $ if prec .eqs. "" then goto p0  $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase") ! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ p0:  $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")o! $ if prec .eqs. "" then goto p0n $ keyfld = f$elem(0," ",prec) 0 $ key = f$extract(0,5,f$element(0,".",keyfld)) $ goto k_PARAM $ k_param: $!< $!	Just extract the second and third part of the key field? $!	and create a global symbol by replacing the dot with a "_"  $! $ s1 = f$elem(1,".",keyfld)  $ s2 = f$elem(2,".",keyfld)m $ v1 = f$elem(1," ",prec)p $ DISABLE_QUEUES = v1n $ goto p0 $ p0:d $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase") ! $ if prec .eqs. "" then goto p0= $ keyfld = f$elem(0," ",prec)$0 $ key = f$extract(0,5,f$element(0,".",keyfld)) $ goto k_PARAM $ k_param: $!< $!	Just extract the second and third part of the key field? $!	and create a global symbol by replacing the dot with a "_"1 $! $ s1 = f$elem(1,".",keyfld)  $ s2 = f$elem(2,".",keyfld)e $ v1 = f$elem(1," ",prec)_ $ DISABLE_JOBS = v1p $ goto p0  $ p0:e $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")e! $ if prec .eqs. "" then goto p0d $ p0:( $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase")a! $ if prec .eqs. "" then goto p0e $ keyfld = f$elem(0," ",prec)e0 $ key = f$extract(0,5,f$element(0,".",keyfld)) $ goto k_WATCH $ k_watch:
 $ k_job: $ goto p0  $ p0:f $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase") ! $ if prec .eqs. "" then goto p0r $ p0:r $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase") ! $ if prec .eqs. "" then goto p0r $ p0:r $ read/end=p0_e inFile rec9 $ prec = f$edit (rec, "uncomment,compress,trim,upcase") ! $ if prec .eqs. "" then goto p0 $ p0:$ $ read/end=p0_e inFile rec	 $ p0_e:  $ close inFile $! $! $! Get all the queue names $!& $ tmp = f$getqui("")	! reset context $! $ cnt = 0e $ l0:s6 $ qname = f$getqui("display_queue","queue_name","*")& $ if qname .eqs. "" then goto l0_end $ qn_0 = qname $ cnt = cnt + 1r $ goto l0s $ l0: 6 $ qname = f$getqui("display_queue","queue_name","*")& $ if qname .eqs. "" then goto l0_end $ qn_1 = qname $ cnt = cnt + 