Joe*_*ina 5 bash shell while-loop
我的bash脚本遇到了一些问题.我的脚本和其他东西是启动服务器,需要一些时间才能开始.为了对抗长时间启动,我已经放入了一个查询服务器的while循环,看看它是否正在运行.
while [ $running -eq 0 ]; do
echo "===" $response "===";
if [ "$response" == "" ] || [ "$response" == *"404 Not Found"* ]; then
sleep 1;
response=$(curl $ip:4502/libs/granite/core/content/login.html);
else
running=1;
fi
done
Run Code Online (Sandbox Code Playgroud)
当退出循环时,$ response等于"404"字符串.如果是这样的话,那东西应该还在循环中,不应该吗?似乎我的循环过早退出.
乔
[ .. ]与glob不匹配.用途[[ .. ]]:
if [ "$response" == "" ] || [[ "$response" == *"404 Not Found"* ]]; then
Run Code Online (Sandbox Code Playgroud)