#!/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 disk
#
rdcmd="
    tar cvf - $fromPath
    if [  \$? -ne 0 ]
    then
        echo 1
        exit 1
    fi
    "

#
# Write to tape
#
wrcmd='
    dd of=/dev/rmt/tps0d6
    if [  $? -eq 0 ]
    then
        echo 0
        exit 0
    else
        echo 1
        exit 1
    fi
    '

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

echo $tarok
exit 0
