Created
April 24, 2013 08:12
-
-
Save netwjx/5450495 to your computer and use it in GitHub Desktop.
batch upload files through by ftp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
passive模式需要在31行插入passive