#
#  time_cta: Script to print the names of the first and last
#            tar files on a tape.
#
if ( $#argv > 0 && $1 == "1" ) then
   mt -f /dev/rmt/1 rewind
   echo -n "First file: "         # Print name of first file
   tar tf /dev/rmt/1n
   mt -f /dev/rmt/1n eom          # Find beginning of last file
   mt -f /dev/rmt/1n nbsf 1
   echo -n "Last file:  "         # Print name of last file
   tar tf /dev/rmt/1
#  mt -f /dev/rmt/1 offline       # Eject the tape
else
   mt -f /dev/rmt/0 rewind
   echo -n "First file: "         # Print name of first file
   tar tf /dev/rmt/0n
   mt -f /dev/rmt/0n eom          # Find beginning of last file
   mt -f /dev/rmt/0n nbsf 1
   echo -n "Last file:  "         # Print name of last file
   tar tf /dev/rmt/0
#  mt -f /dev/rmt/1 offline       # Eject the tape
endif
