SAY "-------------------------------------------" SAY " START COPY PROCEDURE" SAY "-------------------------------------------" ! sic\sic log data_current: "/data/CURRENT/" sic\sic log data_finished: "/data/FINISHED/" sic\sic log copy_current: "/copy/CURRENT/" ! if .not.exist(file) then def char file*40 status*10 obsfile*40 rdifile*40 /global def logical empty /global endif def integer ier CLIC\SET SORT SCAN if .not.exist(in_file) then CLIC\VAR READ ON endif ! ! Infinite loop ! for /while YES let empty NO let status " " ! ! FIRST make sure all files in FINISHED have been fully copied: ! for /while .not.empty system "!2>/dev/null nextfile /data/FINISHED" @ nextfile if .not.empty then say " " say "I-COPY, Finish Copy from DATA_FINISHED:"'file' CLIC\FILE IN DATA_FINISHED:'file' CLIC\FILE OU COPY_CURRENT:'file' 'status' CLIC\FIND/NUM OXNEXT * IF (FOUND.GT.0) then CLIC\COPY DATA NOANT NOBASE NOCHECK endif system "!mv /data/FINISHED/"'file'" /data/COPIED" system "!cp /data/FINISHED/"'obsfile'" /copy/COPY" system "!chmod u+w /copy/COPY/"'obsfile' system "!mv /data/FINISHED/"'obsfile'" /data/COPIED" system "!cp /data/FINISHED/"'rdifile'" /copy/COPY" system "!chmod u+w /copy/COPY/"'rdifile' system "!mv /data/FINISHED/"'rdifile'" /data/COPIED" system "!mv /copy/CURRENT/"'file'" /copy/COPY" endif next ! ! SECOND look for file in CURRENT: ! let empty NO system "!2>/dev/null nextfile /data/CURRENT" @ nextfile if .not.empty then CLIC\FILE OU COPY_CURRENT:'file' 'status' say " " say "I-COPY, Loop Copy from DATA_CURRENT:"'file' let ier 0 FOR/WHILE YES ! ! the procedure exits when the input file is removed (e.g. moved to FINISHED) on error break CLIC\FILE IN DATA_CURRENT:'file' on error CLIC\FIND/NUM OXNEXT * IF (FOUND.GT.0) then ON ERROR CONTINUE CLIC\COPY DATA NOANT NOBASE NOCHECK ON ERROR let ier 0 SIC WAIT 5.0 ELSE if (ier.ge.3) then say 'ier' " timeouts: type CONTINUE to go on" PAUSE let ier 0 else SAY "I-COPY, Waiting for new data in file DATA_CURRENT:"'file'" ..." on error let ier ier+1 CLIC\NEW 3 1000 on error endif NEXT endif if status.eq." " then system "!echo I-COPY, $(date) No file found" sic wait 10 endif NEXT exit SAY "-------------------------------------------" SAY " END COPY PROCEDURE" SAY "-------------------------------------------"