关于猛砸,直到重复 [英] Bash about repeat until
本文介绍了关于猛砸,直到重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道的语法是否正确。我不能测试它现在很抱歉,但对我很重要。它的一个FTP脚本。该文件名为 A.TXT
,我想创建一个脚本,将上传文件,直到成功为止。它将作品或没有?任何人都可以帮助我建立正确的PLS
LOGFILE = /家庭/ transfer_logs / $ a.log
DIR = /家庭/发
搜索=`LS /家庭/ send`
FIRSTLINE =`egrep的连接$ LOGFILE`
secondline =`egrep的文件传输成功$ LOGFILE`如果[-z$搜索];然后
CD $ DIR
FTP -p -v -i 192.163.3.3< ../../example.script> ../../$LOGFILE 2 - ;&放大器; 1
科幻如果
egrep的未连接$ LOGFILE;然后
重复
FTP -p -v -i 192.163.3.3< ../../example.script> ../../$LOGFILE 2 - ;&放大器; 1
直到
[[-n $ FIRSTLINE&放大器;&安培; $ secondline]];
DONE
科幻
example.script包括:
二进制
MPUT A.TXT
放弃
解决方案
确实 FTP
不会返回一个合理的结果?这将是最容易写:
一会儿! FTP ...;做睡1; DONE
如果你坚持要搜索的日志文件,这样做:
时:;做
FTP ...> $ LOGFILE
grep的-qf文件传输成功$ LOGFILE和放大器;&安培;打破
DONE
或者
一会儿!测试-e $ LOGFILE || grep的-qf未连接$ LOGFILE;做
FTP ...> $ LOGFILE
DONE
I want to know about that syntax is correct or not. I cant test it right now sorry, but its important for me. Its an FTP script. The file name is a.txt
, I would like to create a script that will upload a file until it is successful. It will works or not? Anyone can help me to build the correct one pls
LOGFILE=/home/transfer_logs/$a.log
DIR=/home/send
Search=`ls /home/send`
firstline=`egrep "Connected" $LOGFILE`
secondline=`egrep "File successfully transferred" $LOGFILE`
if [ -z "$Search" ]; then
cd $DIR
ftp -p -v -i 192.163.3.3 < ../../example.script > ../../$LOGFILE 2>&1
fi
if
egrep "Not connected" $LOGFILE; then
repeat
ftp -p -v -i 192.163.3.3 < ../../example.script > ../../$LOGFILE 2>&1
until
[[ -n $firstline && $secondline ]];
done
fi
example.script contains:
binary
mput a.txt
quit
解决方案
Does ftp
not return a reasonable result? It would be easiest to write:
while ! ftp ...; do sleep 1; done
If you insist on searching the log file, do something like:
while :; do
ftp ... > $LOGFILE
grep -qF "File successfully transferred" $LOGFILE && break
done
Or
while ! test -e $LOGFILE || grep -qF "Not connected" $LOGFILE; do
ftp ... > $LOGFILE
done
这篇关于关于猛砸,直到重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文