前一段在客户处,发现他们效率较低,帮他们写了几个自动化处理脚本,这是一个收集数据的脚本,上传数据脚本类似,另外利用expect可以做一些telnet的自动登录事情,可以节省不少时间。
#!/bin/ksh
echo "Usage: $0 FtpConfigFile [DownFiles]"
echo "Usage: $0 ftp配置文件 [待下载文件]"
if [ $# -lt 1 ]; then
echo "Pls check arguments!"
exit
elif [ $# -eq 1 ]; then
FTPConf=$1
oridir="./"
file="*"
elif [ $# -eq 2 ]; then
FTPConf=$1
oridir="./"
file=$2
fi
line=""
while read line
do
IP=`echo $line|awk '{print $1}'`
echo "************************************************"
echo "Begin to download files to machine:$IP"
user=`echo $line|awk '{print $2}'`
passwd=`echo $line|awk '{print $3}'`
aimdir=`echo $line|awk '{print $4}'`
ftp -i -n $IP <
user $user $passwd
bin
cd $aimdir
lcd $oridir
prompt
mget $file
bye
FTP
echo
echo "Finish to download files to machine:$IP"
echo "************************************************"
echo
done < ./$FTPConf
######################################
down.conf:配置文件格式
192.168.0.100 root *** /tmp/****
收起