[comp.sys.ncr] tape copying, byte swapping, etc.

jalsop@seachg.UUCP (John Alsop) (01/21/90)

Here's a little shell script that should handle most copying from 150MB to
45MB tape drives.

Undocumented and unsupported, but usage should be fairly obvious.


John Alsop

Sea Change Corporation
1100 Central Parkway W., Suite 38
Mississauga, Ontario, Canada L5C 4E5
Tel: 416-272-3881 Fax: 416-272-1555
UUCP: ...!uunet!attcan!darkover!seachg!jalsop

The following is a shar script.
----------------CUT HERE------------------------------------
echo x - copytape
sed 's/^X//' >copytape <<'*-*-END-of-copytape-*-*'
X#-------------------------------------------------------------------------
X# copytape - copy tape from 150 MB to 45 MB tape drives, handling byte
X#            swapping correctly
X#
X# Usage: copytape [numfiles]		(default is to copy 1 file)
X#
X# Revision History
X#
X# Jan 1990	Original version (jalsop@seachg.UUCP)
X# 
X#-------------------------------------------------------------------------
X
Xcase $# in
X	0)	numfiles=1;;
X	1)	numfiles=`expr $1 : '\([0-9][0-9]*\)'`
X		if test "$numfiles" != "$1"; then
X			echo Usage: copytape [numfiles]
X			exit 1
X			fi;;
X	*)	echo Usage: copytape numfiles
X		exit 1;;
X	esac
X
X# define tape drive names
X
Xtp150=/dev/rstp/34yy
Xtp150n=/dev/rstp/34nn
Xtp45=/dev/rstp/0yy
Xtp45n=/dev/rstp/0nn
X
X# make sure they exist
X
Xfor i in $tp150 $tp150n $tp45 $tp45n; do
X	if test ! -c $i; then
X		echo bad tape device name $i
X		exit 1
X		fi
X	done
X
Xecho "\nPlace input tape in 150MB drive, and output tape in 45 MB drive."
Xecho Press RETURN when ready
Xread ans
X
Xecho Rewinding ...
X< $tp150
Xif test $? -ne 0; then
X	echo "rewind of $tp150 failed"
X	exit 1
X	fi
X< $tp45
Xif test $? -ne 0; then
X	echo "rewind of $tp45 failed"
X	exit 1
X	fi
X
X# get current swap state
X
Xoldswap=`/menu/obj/mtswap.o $tp150 -tell`
X
Xecho "Disabling swap on 150MB tape ... - \c"
X/menu/obj/mtswap.o $tp150 -set 0
X
X# copy the files
X
Xfile=1
Xwhile test $file -le "$numfiles"; do
X	echo Copying file $file ...
X	dd if=$tp150n bs=200k of=$tp45n
X	if test $? -ne 0; then
X		echo I/O error copying file $file
X		echo "Resetting previous swap state ... - \c"
X		/menu/obj/mtswap.o $tp150 -set $oldswap
X		exit 1
X		fi
X	file=`expr $file + 1`
X	done
X
Xecho $numfiles files copied.
X
Xecho "Resetting previous swap state ... - \c"
X/menu/obj/mtswap.o $tp150 -set $oldswap
X
Xecho Rewinding ...
X< $tp150
Xif test $? -ne 0; then
X	echo "rewind of $tp150 failed"
X	exit 1
X	fi
X< $tp45
Xif test $? -ne 0; then
X	echo "rewind of $tp45 failed"
X	exit 1
X	fi
X
Xecho tape copy complete.
X
Xexit 0
*-*-END-of-copytape-*-*
exit
-- 
John Alsop

Sea Change Corporation
1100 Central Parkway W., Suite 38
Mississauga, Ontario, Canada L5C 4E5
Tel: 416-272-3881 Fax: 416-272-1555
UUCP: ...!uunet!attcan!darkover!seachg!jalsop