雷振林

雷振林的博客

他的个人主页  他的博客

转载:怎么用shell判断远程ftp是否连接成功

雷振林  2009年11月05日 星期四 10:02 | 2037次浏览 | 0条评论

出处:http://topic.csdn.net/u/20071113/10/a34c5db5-995a-4dc2-b363-8add2de92a30.html

BatchFile code
    

38 # excute upload & record
39 echo "
40 open ${REMOTE_IP}
41 prompt off
42 user ${USER} ${PSWD}
43 lcd ${LOCAL_DIR}
44 cd ${REMOTE_DIR}
45 ${BATCH_PUT}
46 close
47 bye
48
" |ftp -v -n |tee $ {TRANSFER_LOG} |sed 's / ^ />/ g' >> $ {RUN_LOG}
49 TOTAL_TRANSFERED = `grep " 226 Transfer complete " $ {TRANSFER_LOG} |wc -l`
50 echo " TOTAL TRANSFERED: " $ {TOTAL_TRANSFERED} >> $ {RUN_LOG}
51 echo "" >> $ {RUN_LOG}
52
53 BATCH_CLEAN = `grep -B 3 " 226 Transfer complete. " $ {TRANSFER_LOG} |grep " local: " |awk -F " " '{printf ( " '${LOCAL_DIR}'/%s
\n
" ,$ 2 ); }'`
54
55 # clean uploaded files & record
56 echo " Remove all of transfered files: " >> $ {RUN_LOG}
57 COUNT = 0
58 for i in $ {BATCH_CLEAN}
59 do
60 rm -f $ {i}
61 echo $ {i} " DELETED. " >> $ {RUN_LOG}
62 COUNT = `expr $ COUNT + 1 `
63 done
64 echo " TOTAL DELETED: " $ {COUNT} >> $ {RUN_LOG}
65 echo "" >> $ {RUN_LOG}

  53行开始根据传送日志判断是否成功,然后可作相应处理,自己修改一下吧
 

评论

我的评论:

发表评论

请 登录 后发表评论。还没有在Zeuux哲思注册吗?现在 注册 !

暂时没有评论

Zeuux © 2024

京ICP备05028076号