PRO storlogs,year,month,day,quiet=quiet ; This procedure detects any log files in /jasper/cnsr3_data1/log ; for the given date, creates a subdirectory for them if necessary, ; and moves them into the subdirectory after compressing them with ; gzip (where appropriate). It makes extensive use of SPAWNed shell ; commands. ON_ERROR,2 home='/jasper/cnsr3_data1' CD,home+'/log' IF month LT 10 THEN hexmo=STRING(month,FORMAT='(I1)') $ ELSE hexmo=STRING(BYTE(month)+87B) decyr=STRING(year MOD 100,FORMAT='(I2.2)') decmo=STRING(month,FORMAT='(I2.2)') hexdate=STRING(hexmo,day,FORMAT='(A1,I2.2)') decdate=STRING(decmo,day,FORMAT='(A2,I2.2)') logdir=home+'/log/'+decyr+'/'+hexdate cmd='/bin/test -d '+logdir+' ; @ s = 1 - $status ; echo $s' SPAWN,cmd,dir_found ; dir_found returns status of test df=dir_found(0) ; isolate a scalar result of the SPAWNed process IF (df EQ '0') THEN BEGIN ; needed directory not there cmdroot='/bin/mkdir '+logdir ; make log subdirectory cmd=cmdroot+' ; @ s = 1 - $status ; echo $s' SPAWN,cmd,result ; do the 'mkdir' cmd='/bin/test -d '+logdir+' ; @ s = 1 - $status ; echo $s' SPAWN,cmd,dir_found ; dir_found returns status of test df=dir_found(0) ; isolate a scalar result of the SPAWNed process ENDIF IF df EQ 0 THEN MESSAGE,"Couldn't build subdirectory for logs" ELSE BEGIN ; Zeroth, open a new file to receive the shell commands needed jobname=home+'/scripts/mvlog'+STRING(year MOD 100,month,day $ ,FORMAT='(3I2.2)') OPENW,jobunit,jobname,/GET_LUN PRINTF,jobunit,'#/bin/csh -f' ; First ASCIIize, gzip, and move the temperature log file tlfname=home+'/log/ki_temp1.'+hexdate cmd='/bin/test -s '+tlfname cmd=cmd+' ; @ s = 1 - $status ; echo $s' SPAWN,cmd,tlogfound ; does 'ki_temp1.nnn' exist? tlf=tlogfound(0) IF tlf AND (filesize(tlfname) GT 0) THEN BEGIN cmd=home+'/bin/stemp -f '+tlfname $ +' >! '+home+'/log/asctemp1.'+hexdate IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd cmd='/usr/local/bin/gzip -v '+home+'/log/asctemp1.'+hexdate IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd cmd='/usr/bsd43/bin/mv '+home+'/log/asctemp1.'+hexdate+'.gz '+logdir IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd cmd='/usr/bsd43/bin/rm '+tlfname IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Next gzip and move the operations log file olfname=home+'/log/ki_log1.'+hexdate cmd='/bin/test -s '+olfname cmd=cmd+' ; @ s = 1 - $status ; echo $s' SPAWN,cmd,ologfound ; does 'ki_log1.nnn' exist? olf=ologfound(0) IF olf AND (filesize(olfname) GT 0) THEN BEGIN cmd='/usr/local/bin/gzip -v '+olfname IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd cmd='/usr/bsd43/bin/mv '+olfname+'.gz '+logdir IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Now gzip and move any backup log files found blg=FINDFILE(home+'/log/r'+decdate+'?.blg',COUNT=nblg) IF nblg GT 0 THEN BEGIN FOR i=0,nblg-1 DO BEGIN cmd='/usr/local/bin/gzip -v '+blg(i) IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd cmd='/usr/bsd43/bin/mv '+blg(i)+'.gz '+logdir IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDFOR ENDIF ; Now move the boot log file if it's there bootlog=FINDFILE(home+'/log/bootlog.'+hexdate,COUNT=nbootlog) IF nbootlog EQ 1 THEN BEGIN cmd='/usr/bsd43/bin/mv '+bootlog(0)+' '+logdir IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Now move the 'bkupdone.???' file if it's there. bkupdone=FINDFILE(home+'/log/bkupdone.'+hexdate,COUNT=nbkupdone) IF nbkupdone EQ 1 THEN BEGIN cmd='/usr/bsd43/bin/mv '+bkupdone(0)+' '+logdir IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Now move the 'qlook.??' file if it's there. qlook=FINDFILE(home+'/log/qlook.'+STRMID(hexdate,1,2),COUNT=nqlook) IF nqlook EQ 1 THEN BEGIN cmd='/usr/bsd43/bin/mv '+qlook(0)+' '+logdir IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Now delete the census file if it's there census=FINDFILE(home+'/log/census.'+STRMID(hexdate,1,2),COUNT=ncensus) IF ncensus EQ 1 THEN BEGIN cmd='/usr/bsd43/bin/rm '+census(0) IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Now do the same for the 'kibklog*' files if they're there kibk=FINDFILE(home+'/log/kibklog*',COUNT=nkibk) IF nkibk GE 1 THEN BEGIN cmd='/usr/bsd43/bin/rm '+home+'/log/kibklog*' IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Now make the script executable and run it CLOSE,jobunit FREE_LUN,jobunit SPAWN,'/usr/bsd43/bin/chmod 744 '+jobname SPAWN,jobname SPAWN,'/usr/bsd43/bin/rm '+jobname ENDELSE ; We're done RETURN END