自动上传脚本

#!/bin/bash

function upload(){
        ftp -n <<EOF
        open xx.39.248.yy 41413
        user mmsftp mms123$
        binary
        cd $2
        put $1
        bye
EOF
}

for csv in *.csv
do
        if [[ $csv == MmsActive* ]]; then
                upload $csv /Active
        elif [[ $csv == MmsSilent* ]]; then
                upload $csv /Silent
        elif [[ $csv == MmsFail* ]]; then
                upload $csv /Fail/${csv:16:8}
        else
                continue
        fi
        if [ $? -eq 0 ]; then
                rm $csv
                echo "uploaded $csv ok, and deleted it." >>ftp.log
        fi
done

 

posted @ 2014-09-19 20:14  lichmama  阅读(332)  评论(0编辑  收藏  举报