Answer the question
In order to leave comments, you need to log in
How to redirect curl to a variable and compare with a string?
Is there a script something like
status=$(curl -k -Is https://example.com" | head -1)
if [ "$status" = "HTTP/2 200" ]
then
echo -e "Server status OK"
elif [ "$status" = "HTTP/2 401" ]
then
echo -e "Server have problem with auth"
else
echo -e "Server status ERROR"
fi
Answer the question
In order to leave comments, you need to log in
can be easier
status=$(curl -o /dev/null -Iksw "%{http_code}" https://example.com)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question