shell脚本实现FTP自动上传文件
-----多个文件-----
#!/bin/bash ftp -n<<! open 172.20.10.242 user logftp logftp binary cd /data/ftp/pcidata/pcilogftp/AppFile/log lcd /data/localacc prompt mget *.gz close bye !
----单个文件-----
#!/bin/bash ftp -n<<! open 172.20.10.242 user logftp logftp binary cd /AppFile/log lcd /root prompt put install.log close bye !
---脚本---
#!/bin/bash for LOGPATH in `/bin/cat /fs01/scripts/AMS_LogDir.txt` do if [ ! -d ${LOGPATH} ] && [ ${LOGPATH:0:1} != "#" ];then echo "${LOGPATH} This directory does not exist.Please check it!" exit 0 fi done for UP_LOGPATH in `grep -v "^#" /fs01/scripts/AMS_LogDir.txt` do LOGFILE=`/bin/ls -l ${UP_LOGPATH}|tail -1|awk '{print $NF}'` ftp -A -n<<! open x.x.x.x user pcilogftp PciLog binary mkdir ${UP_LOGPATH}/52 cd ${UP_LOGPATH}/52 lcd ${UP_LOGPATH} prompt put ${LOGFILE} close bye ! done
如对您有帮助,支持下呗!
微信
支付宝