0
I built this script to run on Linux, but it is not working as expected.
I’m using the curl
to find the state of the HTTP connection.
He returns to me:
HTTP/1.1 200 OK
Mais alguns conteúdos do site http...
This is the script:
#!/bin/bash
curl-v --head --output /dev/null http://site:port/folder >> relatorios.txt
if ! HTTP_CODE=200 do
echo "operando servico web"; then
echo "Serviço Online"
else
echo "Serviço Offline"
exit 1
fi
exit
I expected it to respond with 200 code online service when it is operating on the network, and offline service with any other code that is termed when a web page is not available, 404, 500 etc..
I turned off the test machine to validate if the message would appear offline but still show online. I would need him to show me the status of when it’s OK and if for any other reason the page goes down, report that the page is out. I would like to use this result field HTTP/1.1 200 OK
because it changes when the page is out.
I did this script on the terminal by vi
, would like to use the curl
to check the status of the web page, but it did not come out as expected. Someone has any suggestions?
Validated the action applied, thank you :-)
– Nepozv
blz. Mark as useful answer (arrow above), Please! :-)
– Incrivel Monstro Verde Cabelud