#!/bin/csh -f
set blocksize = 20

if (($#argv == 3) || ($#argv == 2)) then
   set remhost = $1
   set rtape = $2
else if ($#argv == 3) then
   set blocksize = $3
else
   echo "Usage: $whoami remhost rtape [ blocksize ]"
   exit 1
endif

set i = 0
while (! $?done)
   set f = file$i
   echo "Copying $f from tape to disk"
   rsh $remhost -n "dd if=$rtape bs=${blocksize}b" | dd of=$f bs=${blocksize}b
   if (-z $f) then
      rm $f
      set done
   else	
      @ i++
   endif
end

echo $i files copied
exit 0
