Skip to content

Instantly share code, notes, and snippets.

@OneOfOne
Last active March 4, 2016 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OneOfOne/6598fd2f79145200b512 to your computer and use it in GitHub Desktop.
Save OneOfOne/6598fd2f79145200b512 to your computer and use it in GitHub Desktop.
scp replacement using sftp because scp is a horrible piece of crap.
#!/bin/sh
#
# this script is under public domain, go nuts.
# originally posted by OneOfOne at https://gist.github.com/OneOfOne/6598fd2f79145200b512
#
if [ "$#" -lt 2 ]; then
echo "usage: $0 files... [sftp args] host:/path" > /dev/stderr
exit 1
fi
CMD="sftp -b -"
BATCH="progress\n"
while [[ $# > 0 ]] ; do
arg="$1";
[ ! -f "$arg" ] && break
BATCH="${BATCH}put \"$arg\"\n"
shift
done
BATCH="${BATCH}bye\n"
#echo "echo -n $BATCH | $CMD $@"
echo -ne $BATCH | $CMD $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment