#!/bin/csh -f ############################################################################# # Copyright: J.Brewer/ESO 1999.############################################## ############################################################################# # # Name: ObsLogN # Description: This script will create a catalogue of FITS files # which exist in the calling directory, and then append to this # catalogue as new files arrive. This script is terminated by an # interrupt (^c) upon which an option is given to print the catalogue. # # # Author: James Brewer, jbrewer@eso.org # Version: 1.0, 05 May 1999: First release # Version: 2.0, 16 Jan 2000: Instead of looking for the last wfi*.fits # file, I now use a counter. Previously the script missed odd # files as the ftp is slow and it was possible for two new files # to arrive while waiting for read permission on the first. # ############################################################################# # # Check script arguments... # if($#argv != 0 || $1 == "-help") then goto error endif # # Set variables... # set wait = 10 # Sleep between datafile update checks # # Define action on interrupt (^c)... # onintr cleanup # # On w2p2drs, change to data directory... # echo ">>> Changing directory to /data <<<" cd /data sleep 2 # # Start the catalogue off with existing files (if any). This call # to ObsLog.csh will also generate the catalogue header. # while (`ls wfi*.fits | wc -l` == 0) # There are *no* files. Wait a while... sleep $wait end ObsLog.csh wfi*.fits # # Start an infinite loop to update catalogue... # set n = `ls -1 wfi*.fits | tail -1 | tr -d wfi.fits` while(1) # # Increment file counter, create new file name... # @ n+=1 set new="wfi"$n".fits" # # Wait for new file to arrive and to be readable... # while !(-r $new) sleep $wait end # # File has arrived, and can be read. Add to the catalogue... # ObsLog.csh -a $new end exit(0) cleanup: # # Call up the log printing command... # ObsLog.prt exit(0) error: echo "Usage: "$0 echo " " echo "[Further information --> "$0" -help]" echo "[See this script --> more `which "$0"`]" if($1 == "-help") then more `echo $0 | sed -e s/ObsLogN/ObsLog.man/` endif exit(-1)