#! /usr/bin/sh
#
#ident	"@(#)rcp.sh	1.8	04/12/08 SMI"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# by Mark F. Logan
# Modified by Andrew McCarthy

if [ $# -ne 1 ]
then
	echo usage: $0 dest-machine
	exit 1
fi

echo Runtime: $RUNTIME seconds
sleep $RUNTIME &
sleepid=$!
iter=1

echo Changing local directory to /tmp
cd /tmp

local=`hostname`

while [ -d /proc/$sleepid ]
do
	date
	rcp /usr/bin/sh $1:/export/home/tmp/sh.$local.$$
	rcp $1:/export/home/tmp/sh.$local.$$ sh.$$
	if cmp sh.$$ /usr/bin/sh 
	then
		rm sh.$$
		rsh $1 "rm /export/home/tmp/sh.$local.$$"
	else
		echo "!ERROR: cmp failed on iteration $iter"
		exit $?
	fi
	iter=`expr $iter + 1`
	sleep 1
done

echo "!PASS: Completed $iter copies successfully"
