有问题比较2响应的代码的外壳。 跑卷和需要验证,如果回应的是200至400人。 此外,有机会的反应是"000"当一个服务器已关闭。
#!/bin/sh
response1="200" #curl first url
response2="000" #curl second url
if (( $response1 -ge 400 || $response1 -lt 200 || $response2 -ge 400 || $response2 -lt 200 )) ; then
echo "Something went wrong, response code is not in success range"
exit 1
else
echo "Success"
exit 0
fi
((:200-ge400 || 200 -lt200 || 000 -ge400 || 000 -lt200:中的语法错误的表达(错误的令牌"400 || 200 -lt200 || 000 -ge400 || 000 -lt200")
如果我改变括号内的[[...]]它总是返回正确的。 如果我改变-lt<和ge>=获得的以下错误:
((: 200 = 400 || 200 < 200 || 000 = 400 || 000 < 200 : 尝试分配给非可变(错误的令牌"= 400 || 200 < 200 || 000 = 400 || 000 < 200 ")