shell脚本实现FTP自动上传文件

时间:2022-08-21 19:18:19

-----多个文件-----

#!/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

相关文章