1 #!/bin/bash 2 3 #批量文件上传脚本 4 5 usage() { 6 echo "Usage: $PROG_NAME {./路径/} {file1} {file2} {file3} ......" 7 exit 1 8 } 9 10 if [ $# -lt 1 ]; then 11 usage 12 fi 13 14 CDN_IP=(\'10.247.22.100\' \'10.247.22.146\') 16 17 FTP_USER=\'user\' 18 FTP_PWD=\'pass\' 19 20 path=$1 21 file=$2 22 args=$# 23 24 PROG_NAME=$0 25 CURR_PATH="$(cd "$(dirname "$0")" && pwd)" 26 27 echo "参数个数 $args" 28 29 for ((i = 2; i <= $args; i++)); do 30 result=$(eval echo \'$\'"$i") 31 echo "begin upload file========>>>>"$result 32 sleep 1 33 34 for ((j = 0; j < ${#CDN_IP[*]}; j++)); do 35 ftp -n ${CDN_IP[$j]} <<EOF >/dev/null 2>&1 36 user $FTP_USER $FTP_PWD 37 binary 38 cd $1 39 put $result 40 prompt 41 bye 42 EOF 43 [ $? -eq 0 ] 44 echo "\033[32m ftp upload ${CDN_IP[$j]} success \033[0m" 45 done 46 done