How can I return 0 when the response status is 200?
Right now I'm able to get the status, e.g., 200 with the following command:
curl -LI http://google.com -o /dev/null -w '%{http_code}\n' -s
But I need to turn this 200 in a return of 0.
How can I achieve this?
I tried the following command, but it doesn't return:
if [$(curl -LI http://google.com -o /dev/null -w '%{http_code}\n' -s) == "200"]; then echo 0
You can also use the -f parameter:
(HTTP) Fail silently (no output at all) on server errors. This is mostly done to better enable scripts etc to better deal with failed attempts.
So:
curl -f -LI http://google.com
Will return status 0 if the call was sucessful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With