Mag Tape Duplication Problems
Geoff Clare
gwc at root.co.uk
Tue Mar 1 01:09:10 AEST 1988
When I actually got round to trying out the script I posted, there
were a few problems with it I had not forseen (OK, I know I should
have tried it *before* I posted it, but I was short of time, sorry).
The main problem was that because the first loop was on the end of a pipe
it was executed in a subshell, so all those carefully stored block
counts were not available to the second loop. This has been
cured by having the entire script from that point down executed as
a subshell receiving the data from the pipe.
Here is the updated version:
----------------------------- cut here ----------------------------
:
# shell script to copy mag tape to multiple cartridge volumes and back
BLOCKSIZE=10k # mag tape block size required
MAGTAPE=/dev/rmt8 # name of mag tape device
CARTRIDGE=/dev/rct # name of cartridge device
BLOCKSPERVOL=40000 # no. of 512 byte blocks to fill cartridge tape
IFS="+$IFS" # add '+' to field seperator list to ease splitting of
# dd block counts
# direct dd output into remainder of script as single subshell, instead of
# just the first loop, to allow $b1 $b2 etc. to be accessed in the second loop
dd if="$MAGTAPE" ibs="$BLOCKSIZE" | (
# write cartridges until < requested no. of blocks are transferred
blocks="$BLOCKSPERVOL"
vol=1
while test "$blocks" -eq "$BLOCKSPERVOL"
do
echo "insert cartridge $vol and press RETURN"
read a </dev/tty
a=`dd count="$BLOCKSPERVOL" of="$CARTRIDGE" 2>&1`
echo "$a"
set -- $a
blocks=`expr $1 \+ $2`
eval b"$vol"="$blocks"
vol=`expr $vol \+ 1`
done
echo "insert blank mag tape to receive copy and press RETURN"
read a </dev/tty
# write back cartridges - no of blocks on each volume is in b$vol
outvol=1
while test "$outvol" -lt "$vol"
do
echo >&2 "insert cartridge $outvol and press RETURN"
read a </dev/tty
eval blocks=\$b"$outvol"
echo >&2 "block count should be $blocks"
dd count="$blocks" if="$CARTRIDGE"
outvol=`expr $outvol \+ 1`
done | dd obs="$BLOCKSIZE" of="$MAGTAPE"
)
----------------------------- cut here ----------------------------
--
Geoff Clare UniSoft Limited, Saunderson House, Hayne Street, London EC1A 9HH
gwc at root.co.uk ...!mcvax!ukc!root44!gwc +44-1-606-7799 FAX: +44-1-726-2750
More information about the Comp.unix.questions
mailing list