我想创建一个脚本来上传文件,直到上传成功。该脚本将监视日志文件。如果"未连接"到服务器,我想重复上传操作,直到"连接"和"文件成功传输"任何人都可以帮助我构建正确的。如果 egrep "不是...",我应该写什么?
LOGFILE=/home/transfer_logs/$a.log
First=$(egrep "Connected" $LOGFILE)
Second=$(egrep "File successfully transferred" $LOGFILE)
ftp -p -v -i 192.163.3.3 < ../../example.script > ../../$LOGFILE 2>&1
if
egrep "Not connected" $LOGFILE; then
ftp -p -v -i 192.163.3.3 < ../../example.script > ../../$LOGFILE 2>&1
until
[[ -n "$first" ]] && [[ -n "$second" ]];
done
fi
示例包含:
binary
mput a.txt
quit
while :; do
ftp ... > $LOGFILE
grep -qF Connected $LOGFILE &&
grep -qF "File successfully transferred" $LOGFILE && break
done