bash 中用curl 判断200状态码

发布于 / 随记 / 0条评论 / Tags: none / 9 次浏览

bash中判断curl返回状态码

代码如下:


response=$(
    curl https://greenhtml.com/asdf/rer.html \
        --write-out %{http_code} \
        --silent \
        --output /dev/null \
)

echo $response 
if test "$response" -ge 200 && test "$response" -le 299 
then 
echo 'check point success'
else 
echo 'check point fail'
exit 1
fi

    评论区(暂无评论)