PRO storelogs,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) 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/'+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 cmd='/bin/test -s '+home+'/log/ki_temp1.'+hexdate cmd=cmd+' ; @ s = 1 - $status ; echo $s' SPAWN,cmd,tlogfound ; does 'ki_temp1.nnn' exist? tlf=tlogfound(0) IF tlf THEN BEGIN cmd=home+'/bin/stemp -f '+home+'/log/ki_temp1.'+hexdate+' >! '+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 '+home+'/log/'+hexdate IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd cmd='/usr/bsd43/bin/rm '+home+'/log/ki_temp1.'+hexdate IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd ENDIF ; Next gzip and move the operations log file cmd='/bin/test -s '+home+'/log/ki_log1.'+hexdate cmd=cmd+' ; @ s = 1 - $status ; echo $s' SPAWN,cmd,ologfound ; does 'ki_log1.nnn' exist? olf=ologfound(0) IF olf THEN BEGIN cmd='/usr/local/bin/gzip -v '+home+'/log/ki_log1.'+hexdate IF KEYWORD_SET(quiet) THEN cmd='('+cmd+') >&! /dev/null' PRINTF,jobunit,cmd cmd='/usr/bsd43/bin/mv '+home+'/log/ki_log1.'+hexdate+'.gz '+home+'/log/'+hexdate 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 '+home+'/log/'+hexdate 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)+' '+home+'/log/'+hexdate 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