Listing 2: vol_change.ksh -- The tape change script
#!/bin/ksh
#
# vol_change.ksh: The script called to change media
# on the TZ877 and issue the
# vol_change command via isql
#
#
# Assign stdin to SESSION_ID
#
alias duplicate=exec
duplicate 3<&0
duplicate 0<&3
read -r SESSION_ID
#
# Determine the next tape and assign it to TAPE
#
if [ ${TAPE} = 6 ]
then
TAPE=0
else
TAPE=`expr 1 + ${TAPE}`
fi
#
# Check the status of the tape drive and
# position the proper starting tape
#
SLOT=`expr 256 + ${TAPE}`
DRIVE_STATUS=`mcutil -e d:0 | awk '{print $3}' | \
awk 'FS="," {print substr($1,2)}'`
case ${DRIVE_STATUS} in
empty)
mcutil -m s:${TAPE} d:0
;;
full)
SOURCE=`mcutil -e d:0 | awk '{print $3}' | \
awk 'FS="," {print substr($3,8,3)}'`
if [ ${SOURCE} != ${SLOT} ]
then
mcutil -m d:0 s:`expr ${SOURCE} - 256`
mcutil -m s:${TAPE} d:0
fi
;;
esac
#
# Issue the vol_changed command via isql
#
${SYBASE}/bin/isql -Usa -P${PASSWORD} -S${SERVER} \
<< ENDSQL
sp_volchanged ${SESSION_ID}, '${DEVICE}', PROCEED
go
ENDSQL
#
# Timestamp tape change via logger(1)
#
logger -p local1.info "Backup tape change completed"
exit 0
# End of File
|