Path: utzoo!mnetor!uunet!mcvax!ukc!stc!root44!gwc From: gwc@root.co.uk (Geoff Clare) Newsgroups: comp.unix.questions Subject: Re: Mag Tape Duplication Problems Message-ID: <550@root44.co.uk> Date: 29 Feb 88 15:09:10 GMT References: <351@wpg.UUCP> <549@root44.co.uk> Reply-To: gwc@root44.UUCP (Geoff Clare) Organization: UniSoft Ltd, London, England Lines: 70 Summary: News script - Bugs fixed 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 &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 &2 "insert cartridge $outvol and press RETURN" read a &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@root.co.uk ...!mcvax!ukc!root44!gwc +44-1-606-7799 FAX: +44-1-726-2750