Bash: check if site is up or down

I have a few self hosted sites and I have been looking for a way to monitor the site statuses in a way that I will get an email when a site is down and another one once that site is back up again. So I decided to write a little bash script that can run on my home linux server. Here is the code:

This bash script can also run on Mac or Windows. Bash comes standard on Mac OSX. On windows you will need to install Bash and other GNU tools. I might do a post on how to set this up later. The sendEmail program used in the script did not come standard on my linux box, but it was easily installed with one command line:

sudo apt-get install sendemail

The sendEmail website can be found here.