#!/bin/ksh
# @(#) $Id$
#==============================================================================
# This will list and describe tape devices
#==============================================================================
 
#===============================================================================
# Get the tape device by looking in $1. If that's not set,
# try FTT_TAPE. If that's not set either, then exit.
export FTT_TAPE
FTT_TAPE=${1:-${FTT_TAPE:-""}}
FTT_TAPE=${FTT_TAPE:?"No device specified"}
#===============================================================================

listfile=/tmp/list$$
dupfile=/tmp/dup$$
echo " "
date
 
${FTT_DIR}/bin/ftt_test << EOD 2>&1 | tee $listfile
ftt_open
ftt_list_all
ftt_close
quit
EOD

sort $listfile | uniq -c | grep -v '^  *1 ' > $dupfile
if [ -s $dupfile ]
then
    echo "Duplicate listing of:"
    cat $dupfile
fi

echo "Device Descriptions:"
cat $listfile  | (
   echo ftt_open
   read line
   while read tape
   do
       echo ftt_echo $tape
       echo ftt_describe_dev $tape
   done
   echo ftt_close
)  | ${FTT_DIR}/bin/ftt_test
echo " "

rm -f $listfile $dupfile
