Operating System - HP-UX
1819576 Members
2880 Online
109603 Solutions
New Discussion юеВ

DDS : script/program to change tapes in a C1533A DDS autoloader

 
SOLVED
Go to solution
Charles Keenan
Occasional Advisor

DDS : script/program to change tapes in a C1533A DDS autoloader

Hi all,

I am sure I used to have a program/script to programmatically load the next tape in an autoloader ... For us "mean" Scots using expensive 3rd part software is not a cheap option so using free "stuff" is a lot more palatable.

Mucho-ta for karma-shift
ochayethinoojimmy
3 REPLIES 3
Simon Hargrave
Honored Contributor

Re: DDS : script/program to change tapes in a C1533A DDS autoloader

You should be able to use the "mc" command to do what you want. I'm not sure of the full syntax of this command (we do it the expensive way!), but the man page should give you what you want.

Sy
Armin Feller
Honored Contributor
Solution

Re: DDS : script/program to change tapes in a C1533A DDS autoloader

The script expects the 1st medium to be already loaded into the drive. This is
done to prevent the script from accidently overwriting media. On each
invocation it successively loads media from the $MC_MEDIALIST. 'mt offl'
and 'mt ret' commands are used to improve the script's robustness.


#!/usr/bin/sh
# fbackup(1M) chgvol script using mc(1M)
# @(#)chgvol-dk(2001-11-22)
# this script is provided 'as is' and is unsupported by HP
#

# needs to be customized
SPT=/dev/rscsi/c0t3d1 # exchanger control device (picker)
DRIVE=/dev/rmt/c0t3d0BEST # tape raw device

# slots and drive to use, see mc(1M) output
set -A MC_MEDIALIST S1 S2 S3 S4 S5
MC_DRIVE=D1

# some useful options
OFFL=1 # try to get drive offline before unloading
REW=1 # wait for drive after loading (until rewind succeeds)
SLEEP="sleep 5" # multi-purpose delay

export PATH=/usr/bin:/usr/sbin
pgm=${0##*/}

offl()
{
integer tries=0
# try until offl succeeds (maximum 10 retries)
while (($tries < 10)) && ! mt -t $1 offl; do
$SLEEP
((tries=$tries+1))
done
$SLEEP
}

rew()
{
integer tries=0
# try until rew succeeds (maximum 10 retries)
while (($tries < 10)) && ! mt -t $1 rew; do
$SLEEP
((tries=$tries+1))
done
}

robot()
{
case $1 in
occupied) mc -p $SPT -r $2 | grep -q "FULL";;
empty) mc -p $SPT -r $2 | grep -q "EMPTY";;
move) mc -p $SPT -s $2 -d $3;;
*) return 1;;
esac
}

load()
{
$SLEEP
if robot move $1 $MC_DRIVE; then
[ "$REW" ] && rew $DRIVE
$SLEEP
return 0
else
print "$pgm: Load of $1 failed!" >&2
return 1
fi
}

unload()
{
$SLEEP
[ "$OFFL" ] && offl $DRIVE
if robot move $MC_DRIVE $1; then
$SLEEP
return 0
else
print "$pgm: Unload of $1 failed." >&2
return 1
fi
}

# main

print "$pgm: [$(date)] starting..." 2>&1
print "$pgm: [$(date)] drive: $DRIVE" 2>&1
print "$pgm: [$(date)] picker: $SPT" 2>&1
print "$pgm: [$(date)] $MC_DRIVE, ${MC_MEDIALIST[@]}" 2>&1

# We want to ensure not to accidently overwrite media...
# so the 1st medium should be loaded manually by someone else.
if robot empty $MC_DRIVE; then
print "$pgm: [$(date)] Please load a medium to $MC_DRIVE!" 2>&1
exit 1
fi

for slot in ${MC_MEDIALIST[@]}; do
if robot empty $slot; then
if robot occupied $MC_DRIVE; then
# slot empty, drive full
print "$pgm: [$(date)] Unloading $MC_DRIVE to $slot ..." >&2
unload $slot
else
# slot empty, drive empty
: do nothing
fi
else
if robot occupied $MC_DRIVE; then
# slot full, drive full
: do nothing
else
# slot full, drive empty
print "$pgm: [$(date)] Loading $slot to $MC_DRIVE ..." >&2
load $slot
exit $?
fi
fi
done
print "$pgm: [$(date)] failed!" 2>&1
exit 1

#eof
Charles Keenan
Occasional Advisor

Re: DDS : script/program to change tapes in a C1533A DDS autoloader

Looks like a flyer ... will give it a spin ... TTFN
ochayethinoojimmy