Overtherailing. RSS

I hope you find the answers faster than I did.

Archive

Mar
22nd
Mon
permalink

Fugly bash script to monitor remote Web server

I bet this can be done better. If you feel the same way, please feel free to edit the following Gist:

http://gist.github.com/340464

#!/bin/bash
 
if test -z "$1"; then
        echo "Usage: curl.sh hostname"
        exit
fi
 
RESULT=`curl -sI ${1}|head -n 1|awk '{ print $2 }'`
 
if [ ${RESULT} -eq "200" ]; then
  # All is well 
  exit
else
  echo "OH NO SOMETHING IS BROKEN -- curl returned HTTP status ${RESULT} when fetching ${1}"
fi
  1. overtherailing posted this