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

1
2
3
4
5
6
7
8
9
10
11
12
#!/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 

----单个文件-----

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash 
ftp -n<<! 
open 172.20.10.242
user logftp logftp
binary 
cd /AppFile/log
lcd /root
prompt 
put install.log
close 
bye 
!

 ---脚本---

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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 -"^#" /fs01/scripts/AMS_LogDir.txt`
do
LOGFILE=`/bin/ls -l ${UP_LOGPATH}|tail -1|awk '{print $NF}'`
ftp --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