错误:[:状态\代码:bash中应为整数表达式

错误:[:状态\代码:bash中应为整数表达式,bash,shell,integer,devops,Bash,Shell,Integer,Devops,我是Unix环境下编程的初学者,刚开始时遇到了一些困难。你能帮我解决这个问题吗 echo "ES Service getting ready, it may take few mins." status_code=-1 while [ "status_code" -ne 200 ] do status_code=$(curl -k --write-out %{http_code} --connect-timeout 10---max-time 20 --silent --output /

我是Unix环境下编程的初学者,刚开始时遇到了一些困难。你能帮我解决这个问题吗

echo "ES Service getting ready, it may take few mins."
status_code=-1
while [ "status_code" -ne 200 ]
do
    status_code=$(curl -k --write-out %{http_code} --connect-timeout 10---max-time 20 --silent --output /dev/null $ES_HOST)
    printf '.'
    sleep 5
done
```strong text

嗯,
-ne
需要一个整数表达式,
“status\u code”
不是整数,是吗?是字符串


$status\u code
将是您要查找的整数。

看起来您在
[“$status\u code”-ne 200]中遗漏了$code