Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am getting http code as 000 or Time out on server for the cURL in shell script

When i am executing this script on server i am getting response code as 000 but i am getting status code as 200 when i am executing this on local machine. This is happening for the same URL & Script.

flag=0
for URL in $@
do
        STATUS=$(curl -s -o /dev/null -w '%{http_code}' $URL)
        if ([ $STATUS -gt 400 ] || [ $STATUS -lt 100 ]); then
               echo $URL "is not working fine, STATUS CODE is "$STATUS
flag=1
        else
               echo $URL "is  working, STATUS CODE is "$STATUS
        fi
done

if [ $flag -eq 1 ]; then
exit 1
fi

I have seen in some forums that the problem is due to SSL. Please let me know what can be changed in above script.

like image 477
Kworks Avatar asked Jan 28 '14 17:01

Kworks


Video Answer


1 Answers

also use -k or the --insecure parameter with your curl commandline to overcome this issue.

like image 52
Sabuj Hassan Avatar answered Oct 19 '22 22:10

Sabuj Hassan