#!/usr/bin/ksh # Written By : Kynan Dent # Written On : Mon Jun 7 12:24:18 EST 2004 # Function : Check if there is a tape in the drive and if so # print the label to stdout # Returns : 0 - Success # 1 - No tape # 2 - No label #set -x # init RETVAL=0 # First, check for a tape. This is what comes back if there is a tape in the drive: #Quantum DLT8000 tape drive: # sense key(0x12)= EOF residual= 0 retries= 0 # file no= 0 block no= 0 # and this is with no tape: # #/dev/rmt/0: no tape loaded or drive offline mt -f /dev/rmt/0 status >/dev/null 2>&1 RETVAL=$? if [ $RETVAL -eq 0 ];then # get the label LABEL=`dd if=/dev/rmt/0 bs=32k 2>/dev/null | tr -d '\014' | head -1` # blank tape? if [ "$LABEL" = "" ];then echo "BLANK tape in drive" else # work out what slot this came from TYPE=`echo $LABEL | sed 's/.*\(JOB_NAME.*\)$/\1/'` echo "slot \c" cat /opt/local/amanda/etc/`echo $TYPE | tr -d '[0-9]'`/tape0-slot | tr -d '\012' echo ": date `echo $LABEL | cut -f4 -d' '` label $TYPE" fi else echo "No tape in drive" fi return $RETVAL