功能:先将文件下载到本机,处理后再ftp上传过去。
#!/bin/sh
# get files
get_file() {
cd /root/xunjian/shipinshangchuan
mv BW-UGC* shipinshangchuan_bak
ftp -i -n 10.199.74.4 << EOF
user xunjian 123456
bin
cd shipinshangchuan
mget BW-UGC-*.txt
mdelete BW-UGC-*.txt
bye
EOF
}
# handle files
handle_file() {
>BW-UGCtemp.txt
for $HOSTNAME in BW-UGC-AMS01 BW-UGC-AMS02 BW-UGC-WPPS01 BW-UGC-WPPS02 BW-UGC-WBPS01 BW-UGC-WBPS02 BW-UGC-AS01 BW-UGC-AS02 BW-UGC-AS03 BW-UGC-AS04 BW-UGC-CS01 BW-UGC-CS02 BW-UGC-CS03 BW-UGC-CS04 BW-UGC-IFS01 BW-UGC-IFS02 BW-UGC-IFS03 BW-UGC-LRS01 BW-UGC-LRS02 BW-UGC-VES01 BW-UGC-VES02 BW-UGC-VES03 BW-UGC-TAS1 BW-UGC-BAKS01 BW-UGC-NMS01 ; do
if [ -f $HOSTNAME*txt ] ; then
egrep "(CST|warning)" $HOSTNAME*txt >> BW-UGCtemp.txt
else
echo "$HOSTNAME" >> BW-UGCtemp.txt
echo "warning!!! $HOSTNAME is down!!!!">>BW-UGCtemp.txt
fi
done
}
# put files
put_file() {
FILE_NAME=`date +%Y-%m-%d-%H-%M-%S`.txt
cat BW-UGC* > $FILE_NAME
ftp -i -n 10.199.74.4 << EOF
user xunjian 123456
bin
cd shipinshangchuan
put $FILE_NAME
bye
EOF
}
# run
get_file
handle_file
put_file
exit 0
阅读(2052) | 评论(0) | 转发(0) |