#! /usr/bin/env bash

destDir='/uploads/'
if [ $# -lt 2 ] ; then
  echo
  echo "Usage:  $0  this-file  this-remote-machine [destination-dir]"
  echo
#- description
  echo " Send file 'this-file' to 'this-remote-machine' (User@Host type)"
  echo "            in dir (on remote) 'destination-dir' (DEF='$destDir')"
  echo "      using system 'sftp' command."
  echo
  exit 9
fi
file=$1
remote=$2
if [ $# -eq 3 ] ; then destDir=$3 ; fi

sftp $remote <<EOF
    put -p $file $destDir
    bye
EOF
retVal=$?
exit $retVal

