Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

FWIW here is how I replaced scp commands in my scripts with sftp. (If there is a better way of course I am interested.)

OLD:

scp $FILE "$USER_AT_HOST:/home/username/dir1/"

NEW (a single embedded newline or Enter right after the word "progress" seemed required, though not correctly displayed here, to enable a visual progress indicator; maybe some kind of \n could work instead but didn't immediately for me and this was easy enough in the end):

echo "progress

put $FILE"|sftp -f -p -N -b - "$USER_AT_HOST:/home/username/dir1/"

OR (single line, without progress indicator):

echo "put $FILE"|nice sftp -f -p -N -b - "$USER_AT_HOST:/home/username/dir1/"

Edit: I suppose this could be carefully put in a script called "scp" that takes parameters, or aliased, something like others here have done with rsync options (^F here for the word "progress" to see some).



ps: FWIW, I made a script and the line with "progress" works on a single line now, not sure what I was doing wrong before. My contact info is in the footer of the web site noted in my profile, if it sounds useful. But the main line is something like this:

echo -e "progress\n put $1"|sftp -CfpN -b - "$2"

Or, to be able to echo it first for confirmation (bash, typed/untested largely from memory not the actual script but close):

#!/usr/bin/env bash

set -eu; set -o pipefail

if [[ #$ -ne 2 ]]; then echo "2 parameters expected"; exit 1; fi

CMD="echo -e \"progress\n put $1\"|sftp -CfpN -b - \"$2\""

echo "Do this (Enter to continue)?: $CMD";read

bash -c "$CMD"; echo "Result: $?"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: