#!/bin/sh

# rput --- put a local file onto a remote machine.  uses automated ftp. 
# very primitive, very dumb.

# first rev, mon, 7jun1999

TMPFILE=/tmp/ftpchat

REMOTEHOST=$2
REMOTEFILE=$3
LOCALFILE=$1

case $1 in
	-h|--help)
		echo
		echo "usage: $0 localfile remotehost remotefile"
		echo "    put a local file onto a remote machine."
		echo "    this is a very primitive substitute for rcp, which uses ftp as the "
		echo "    file transfer mechanism."
		echo
		echo "    a valid .netrc entry is required for remotehost."
		echo "    see the ftp(1) man page for info about .netrc."
		echo
		echo "    all arguments are required.  multiple file copy does not work."
		echo
		exit
		;;
esac


if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
	echo usage: $0 localfile remotehost remotefile
	echo valid .netrc entry is required for remotehost.
	exit
fi

# create the input for ftp
cat >$TMPFILE  <<EOF
put $LOCALFILE $REMOTEFILE
bye
EOF

# call ftp
ftp $REMOTEHOST < $TMPFILE

# clean up after yourself
rm $TMPFILE

