#!/bin/sh
# avoid line too long
# host dir file1 file2 ...

host=$1; shift
dir=$1; shift

mputs=
for f in "$@"; do
  if test ! -s $f; then
    echo "$0: $f not readable or empty, goodbye." >&2
    exit 1
  fi
  target=`basename $f`
  # $'\n' is a bash way of getting a newline.
  mputs="${mputs}put $f $target"$'\n'
done

#hash
if test "$dir" = .; then
  dir=
else
  dir="cd $dir"
fi
ftp -i $host <<END_DOC
$dir
bin
verbose
$mputs
quit
END_DOC 
