我对此很陌生,因此请耐心等待。 我正在尝试在while-do循环中使用curl命令,但成功率很低。 我可以使用循环外的curl命令来获得响应,但是当它碰到while循环时,它会忽略curl命令,并将第一个输出粘贴到文件中,并且在完成时不会打断循环。 我以前运行的命令会向网页输出值“2”,表示它已完成,值“0,1或3”表示尚未完成或错误等。 因为完成此操作可能需要一些时间返回“2”可能需要一段时间,因此循环。 值“0,1,2,3”是硬编码的,不能更改。 该代码的确如此,因为如果你从运行中取消程序,文件确实会得到更新,但它不能在循环过程中看到。我被困在循环中,无法分离它,因为它不会重新访问网页以寻找“2” 任何想法,请 下面是代码的下方在while循环中使用curl命令
curl --location http://$host_name/config-builder-test-app/jobStateResolver?jobId=$jobid > ./jobstate.txt
round=`grep -E "1|0|3" jobstate.txt`
while [ $round ]
do
curl --location http://$host_name/config-builder-test-app/jobStateResolver?jobId=$jobid > ./jobstate.txt
echo "Waiting for confirmation of the completed build:";
sleep 5
done
echo "Successful build for $inputb ID $ID";