johnslattery
11/1/2016 - 3:48 PM

When you can't get people to allow scp.

When you can't get people to allow scp.

transfer_file () {
  local file="$1"
  local remote_dir="$2"
  local remote_file="$3"
  local -i exit_status=0
  sftp -b - "$ssh_user@$ssh_host:$remote_dir" > /dev/null \
    <<< "put $file $remote_file" || {
    exit_status="$?"
    printf "transfer_file: sftp failed putting file '%s'.\n" \
      "$remote_file" >&2
    return "$exit_status"
  }
}