#!/bin/sh

fromPath=$1

#
# the procedure must be modified
#         name of device/tape : /dev/rmt/tps0d6
#         name of host        : crim3
#

#
# Rewind the tape
#
mtcmd='
    mt -t /dev/rmt/tps0d6 rewind
    if [  $? -ne 0 ]
    then
        echo 1
        exit 1
    fi
    '


#
# Read from tape
#
rdcmd='
    dd bs=262144 if=/dev/rmt/tps0d6
    if [  $? -ne 0 ]
    then
        echo 1
        exit 1
    fi
    '

#
# Write to disk
#
wrcmd='(
    tar xBfo - 
    if [  $? -eq 0 ]
    then
        echo "0"
        exit 0
    else
        echo "1"
        exit 1
    fi
    )'

tarok=`/usr/bsd/rsh crim3 "$mtcmd  $rdcmd" | eval "$wrcmd" `

echo $tarok
exit 0

