#!/bin/sh

set -u

if [ "${1:-}" = "-x" ] ; then set -xv; shift; fi
if [ -z "${1:-}" ] ; then echo `date` Usage $0 '<volume|file-with-list-of-volumes>' ; exit 1; fi

if [ -r $1 ]; then
 f=$1
 removef=0
else
 f=/tmp/f.$$.`date +"%s"`
 removef=1
 rm -f $f
 echo $1 >$f
fi

cat $f | while read tape; do
  V=`enstore vol --vol $tape`
  sys_inh=`echo "$V" | grep system_inhibit|cut -f2 -d:`
  lib=`echo "$V" | grep library|cut -f2 -d:`
  vf=`echo "$V" | grep volume_family|cut -f2 -d:`
  n=`enstore fil --ls-active $tape |wc|awk '{print $1}'`
  echo -e $tape "\t" $sys_inh "\t" $lib "\t" $vf "\t" $n files
done
