#
# usage:        trewind.sh
#
# abstract:     This Bourne Shell script rewinds a tape media if required.
#
# note(s):      1. This routine must be called using a . (period)
#
# Copyright (c) 1994-1997 by The MathWorks, Inc.
# $Revision: 1.7 $  $Date: 1997/05/08 22:06:19 $
#----------------------------------------------------------------------------
#
#               	Rewind Tape Media
#               	-----------------
#
    if [ "$REWIND" = "1" ]; then
#
#    Need to use the mt command: Need its location on each system.
#
#	sun4    	/bin/mt -f device {fsf 1| rewind}
#	hp700		/bin/mt -t device {fsf 1| rew}
#       sgi		/bin/mt -f device {fsf 1| rewind}
#       sgi64		/bin/mt -f device {fsf 1| rewind}
#	ibm_rs		/bin/mt -f device {fsf 1| rewind}
#	sol2    	/bin/mt -f device {fsf 1| rewind}
#	alpha   	/bin/mt -f device {fsf 1| rewind}
#
# Try to rewind the device after the first file.
#
	case "$ARCH" in
		hp700)
		    cmd_options2="-t $ARCHIVE_DEVICEN rewind"
		    ;;
		*)
		    cmd_options2="-f $ARCHIVE_DEVICEN rewind"
		    ;;
	esac
#
	ERROR_TAPE_REWIND=0
	mt $cmd_options2 2>$temp_file
	if [ $? -ne 0 ]; then
	    REWIND=
	    nc=`wc -c $temp_file | awk '{print $1}'`
#-----------------------------------------------------------------------------
echo ''
echo ''
echo '---------------------------------------------------------------------'
echo "Error: 'mt $cmd_options2' command failed . . ."
echo ''
	    if [ "$nc" = "0" ]; then
#-----------------------------------------------------------------------------
echo '. . . no message . . .'
#-----------------------------------------------------------------------------
	    else
	        cat $temp_file | awk '{print "" $0}'
	    fi
#-----------------------------------------------------------------------------
echo '---------------------------------------------------------------------'
echo ''
            mesg='Please press <return> to continue: '
            . $dir/$echon_sh
#-----------------------------------------------------------------------------
	    read ans
	    ERROR_TAPE_REWIND=1
	fi
	REWIND=
    fi
