#!/bin/csh -e ############################################################################# # Copyright: J.Brewer/ESO 1999.############################################## ############################################################################# # # Name: ObsLogT # Description: This script will create a catalogue of FITS files # from a tapedrive (specified by the first argument). The catalogue # is made by a call to ObsLog.csh. After the end of data on the tape # is reached, or upon an interrupt signal (^c), an option to print # the catalogue is given. # # # Author: James Brewer, jbrewer@eso.org # Version: 1.0, 5 May99: First release # ############################################################################# # # Check script arguments... # if($#argv != 1 || $1 == "-help") then goto error endif # # Set path needed for other execs... # set path = ($path ~meteolog/scripts) # # Set variables... # set mt = "mt -t" # -t: SunOS, -f: HP set tmp = TapeFile # Name of a tmp file... set first = 1 # Flag used for first entry # # Define action on interrupt (^c)... # onintr cleanup # # Check that the tape drive can be read from... # if !(-r $1) then echo $0": Couldn't find drive "$1" on this machine..." exit(-1) endif # # Start an infinite loop to update catalogue... # while(1) # # Read fits header from tape into a tmp file... # (Note: ObsLog.csh will do the unblocking...) # (dd if=$1 ibs=28800 count=1 >! $tmp) >& /dev/null # # If the header file is empty, we're at end of tape... # (Note: wc does not work on the unblocked tmp file) # if(`ls -l TapeFile | tr -s ' ' | cut -f5 -d' '` == 0) then echo "End of tape reached..." goto cleanup endif # # Header of tape file extracted, add to the catalogue... # if ($first) then ObsLog.csh $tmp set first = 0 else ObsLog.csh -a $tmp endif # # Skip forward to start of the next file... # $mt $1 fsf 1 end exit(0) cleanup: # # Delete the temporary file... # rm $tmp # # Tape handling options... # echo " " echo "Choose:" echo " r -- Rewind " echo " o -- Rewind, take drive offline" echo " x -- Do nothing (default)" echo " " echo -n "Enter your choice... " set reply = $< if ($reply == 'r') then echo "Rewinding tape..." $mt $1 rew endif if ($reply == 'o') then echo "Taking tape offline..." $mt $1 offline endif # # Call up the log printing command... # ObsLog.prt exit(0) error: echo "Usage: "$0" tapedrive" echo " " echo "[Further information --> "$0" -help]" echo "[See this script --> more `which "$0"`]" if($1 == "-help") then more `echo $0 | sed -e s/ObsLogT/ObsLog.man/` endif exit(-1)