(需求实战_02)_ftp连接下载指定.zip类型⽂件⽂章⽬录
⼀、需求⽂档说明
序号要求说明
①协议使⽤ftp协议远程下载
②⽂件类型.zip
③⽂件名acd_UPIDDGWL
④远程下载⽬录APEP/
⑤本服务器下载存放⽬录/ablacklist/xmldata/Lists/PEP
⼆、脚本解释/说明
脚本拆解释义说明执⾏命令
①⽇志⽂件名拼接fname
②错误⽇志拼接elog
③ftp连接格式lftp -u ⽤户名,密码 ftp://IP地址:21 <<EOF > "$fname" 2>&1
④ftp连接栗⼦lftp -u user,123456 ftp://192.168.43.188:21 < “$fname” 2>&1
⑤进⼊到指定⽬录打开本机⽬录⽤lcd 打开远程⽬录⽤cd
⑤下载⽂件mget ⽂件名
注:下⾯是⽇志输出
三、脚本内容
#!/bin/bash
fdate=$(date +%Y%m%d%H%M%S)
flog='/ablacklist/logs/accuitydownload-'
elog='/ablacklist/logs/errors-'
fname=$flog$fdate'.log'
ename=$elog$fdate'.log'
lftp -u ⽤户名,密码 ftp://ip地址:21 <<EOF > "$fname" 2>&1
set xfer:clobber on
cd APEP/
lcd /ablacklist/xmldata/Lists/PEP
mget acd_UPIDDGWL.ZIP
by
EOF
if grep -i "Login failed" "$fname" > /dev/null
then
echo "ERROR: Login failed" >> "$ename"
fi
if grep -i "Not connected" "$fname" > /dev/null
connect下载then
echo "ERROR: Cannot connect to the destination" >> "$ename"
fi
if grep -i "No such file" "$fname" > /dev/null
then
echo "ERROR: Cannot change directory. No such file or directory." >> "$ename"
fi
if grep -i "No such directory" "$fname" > /dev/null
then
echo "ERROR: Cannot change remote directory. No such file or directory." >> "$ename" fi
if grep -i "File or Directory does not exist" "$fname" > /dev/null
then
echo "ERROR: Cannot transfer. File or Directory does not exist" >> "$ename"
fi

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。