#!/bin/csh -f #+ # wftv -- wait for new TV image # # Purpose: # Loop until a new "cam*.fits" image appears in the nightly directory, # and return the name of the image # # Usage: # wftv [-silent] # # Arguments: # -silent = do not echo the name of the TV image # # Output: # Name of the TV image is echoed to STDOUT # # Restrictions: # None # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # # Example: # 1) Wait for a new TV image to appear and echo the name: # wftv # # 2) Wait for new TV image to appear and silently return: # wftv -silent #- # Modification history: # 2002-Jul-02 GDW Original version #----------------------------------------------------------------------- set buf = $0 set cmd = $buf:t set usage = "Usage: $cmd [-silent]" set verb = 1 set interval = 1 # check flags... if ( "$1" == "-silent" ) then set verb = 0 shift endif # verify args... if ( $#argv > 0 ) then printf "$usage\n" exit 1 endif # check the current TV image name... set last = `lasttvimage` # loop until image changes... while (1) set new = `lasttvimage` if ( "$new" != "$last" ) then break endif sleep $interval end # echo name if desired... if ( $verb ) then printf "%s\n" $new endif exit