Skip to content

Instantly share code, notes, and snippets.

@netwjx
Created April 24, 2013 08:12
Show Gist options
  • Save netwjx/5450495 to your computer and use it in GitHub Desktop.
Save netwjx/5450495 to your computer and use it in GitHub Desktop.
batch upload files through by ftp
#!/usr/bin/env bash
updir=.
todir=target/dir
excludes='
upload.sh
TODO.md
node_modules*
package.json
.*
'
paths=`echo "$excludes" | awk '{
if ($0 == "")
next
printf " "$0
}' | sed 's|[^ ]\+|-o -path '\''./\0'\''|g' | sed 's|-o \(.*\)|! \\\\( \1 \\\\)|'`
dirs=`eval 'find '$updir' -type d '$paths' -printf '\''%P\n'\'' | awk '\''{
if ($0 == "")
next
print "mkdir '$todir'/" $0
}'\'`
files=`eval 'find '$updir' -type f '$paths' -printf '\''put %p %P\n'\'`
ftp -nv 1.2.3.4 <<EOF
user username password
type binary
prompt
$dirs
cd $todir
$files
quit
EOF
@netwjx
Copy link
Author

netwjx commented Apr 24, 2013

passive模式需要在31行插入passive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment