http status code is displayed as 200 even if my webserver is not running

194 Views Asked by At

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
0

There are 0 best solutions below