0

I poll a string from an app API that matches with true or false to take further actions.

until curl.../connections|awk -v LID=$LinkID '$0~LID,/}/ {if ($0~/connected/) print}'|grep -q 'connected true,'; do
sleep 5
done
if other condition; then exit 0
fi
while other statement; do
sleep 15
done
shutdown
fi

My problem is that the false value is not reliable from a single poll on the long run in certain circumstances, which leads to a premature done. I'd need the expression between until and do to be re-checked, say 5s after the first one, but I don't know how to this.

Please help

[EDIT] : not sure the title of the thread is well worded

4

1 回答 1

0

我想我是这样理解的(到处都有语法错误,但主要思想在这里):

while true; do
 if [[ curl.../connections|awk -v LID=$LinkID '$0~LID,/}/ {if ($0~/connected/) print}'|grep -q 'connected true,' ]]; then ((++counter))
   if [ $counter -ge 4 ]; then
    break 1
    else sleep 15
    continue 1
   fi
  else
   counter=0; sleep 15
  fi
done 

当预期的目标不存在时,我连接到了持续约 100 万的辅助中继服务器。这只是超时长度的问题

于 2020-06-05T09:19:45.307 回答