0

Even if my webserver is not running, I get the status code 200. Not sure what am i missing?

# Check URL

status_line=`curl -sL -w "%{http_code}\\n" "http://ipaddress:80" -o /dev/null`
status_code=`echo $status_line | awk '{print $0}'`
echo "STATUS_CODE: ${status_code}"
case "$status_code" in
    200) echo 'Success!'
         ;;
      *) echo 'Fail!'
         exit 1
         ;;
esac
  • What is the actual output of curl before you parse it? Are you SURE curl is the one generating the 200 and not a bad AWK parse? And what is the `-sL` parameter? It is not documented on the [curl manpage](http://curl.haxx.se/docs/manpage.html). – Remy Lebeau Sep 03 '14 at 00:34
  • Even if I run "curl -I http://localhost:80" HTTP/1.0 200 OK Date: Wed, 03 Sep 2014 17:32:30 GMT – sjSharks2014 Sep 03 '14 at 17:35
  • curl does not make responses out of nothing. SOMETHING is responding. Maybe YOUR server is not running, but SOMEONE ELSE's server is. Maybe an antivirus or proxy/tunnel or something. Use `netstat` or similar tool to find out what app is actually listening on `localhost:80`. – Remy Lebeau Sep 03 '14 at 17:45

0 Answers0