#!/bin/csh -f # # gp.queue # # Script queues up runs of gp.driver # This script manages working directory # If necessary, it creates day directory # It changes into and out of appropriate day directory # All scripts below this assume user is in appropriate directory # # Input: # Either a command line list of dates # or a file DatesToBeRun # And a file CampaignsToInclude # # W. Prescott # July-November 1995 # # 1995/10/10 whp Converted bard.driver.queue to gp.queue # Restructured to accomodate new working directory # philosophy. # 1996/04/09 whp Added capability to exclude stations with # StationsToExclude file # 1997/12/16 whp Require dates to be read from DatesToRun; # Call gp.CommandLine to process command line arguments. # 1998/04/30 whp Add call to gp.www.NEU at end for each campaign. # (Moved here from gp.driver) # 2000/12/08 whp Eliminated alt designation and made this version official. # 2001/06/08 whp Use gp.SaveLogFile.pl (suid version) # If ProcessFlags file exists remove it before starting # ----------------------------------------------------- if (-e ProcessFlags) rm -f ProcessFlags # Check number of arguments (and save to ProcessFlags) # ---------------------------------------------------- gp.CommandLine $argv if ($status != 0) then echo "gp.driver: gp.CommandLine failed" echo "gp.driver: Terminating" exit 1 endif # Check for list of desired campaigns # ----------------------------------- if (! -e CampaignsToInclude) then echo "gp.queue: File CampaignsToInclude not found" echo "gp.queue: Terminating" exit 1 endif echo "gp.queue: Processing started: " echo gp.queue: `date` echo "gp.queue: " cat ProcessFlags # Store Dates to be run. # ---------------------- echo " " if( -e DatesToRun) then set Dates = `sed -n '/.*/p' DatesToRun` # (Note: sed ignores blank lines in file) else echo Usage: Put dates in file DatesToRun exit 1 endif # LOOP ON DATES # ------------- foreach Date ($Dates) echo " " echo gp.queue: Running $Date set Path = `pwd` # set Disk = `echo $Path | awk '{ if (index(substr($1,2),"/")>0) print substr($1,1,index(substr($1,2),"/")); else print substr($1,1) }'` # set dspace = `df -k | grep $Disk'$'` # echo "gp.queue: Available space" # echo "gp.queue: $dspace" # if ($dspace[4] < 100000) then # echo gp.queue: Not enough disk space # echo gp.queue: stops # exit # endif if (! -e $Date ) then mkdir $Date chmod 775 $Date endif # Run gp.driver # ------------- set Logname = "$Date.log" cp CampaignsToInclude $Date if (-e StationsToExclude) then cp StationsToExclude $Date endif if (-e ProcessFlags) then cp ProcessFlags $Date endif cd $Date echo "gp.queue: Calling gp.driver with -->$Date<-- at:" date gp.driver -d $Date >& driver_log set DriverTermStatus = $status # cp driver_log ../$Logname cd .. # If driver terminated normally, # save log file and delete directory. # ----------------------------------- if ($DriverTermStatus == 0) then echo gp.queue: Deleting $Date directory and saving log file. gp.SaveLogFile.pl $Date gp.DeleteAllDebris $Date if (`grep Save ProcessFlags | awk '{print $2}'` != "yes") then rm -fr $Date endif rm -f junk_file else echo gp.queue: gp.driver returned non-zero status processing $Date. echo gp.queue: Directory not deleted. if (`grep Save ProcessFlags | awk '{print $2}'` != "yes") then gp.DeleteDebris $Date endif rm -f junk_file endif echo "gp.queue: Done with $Date" date end # End loop on dates # Update results on web # --------------------- set Campaigns = `cat CampaignsToInclude` foreach Camp ($Campaigns) if ($Camp != "XXXXXXXXXXXXXXXX") then gp.www.neu.pl $Camp endif end echo "gp.queue: Done" date exit