#!/bin/bash #Checks if a site correctly answers to a HEAD query, #if it does not answers correctly beep and send a message #You can also provide a filename with an URL on each line home='/path/to/homefolder' targetfile="$home/Desktop/SITES_NOT_RESPONDING" function checksite(){ HEAD "$1" > "$home/output" grep "^4[0-9][0-9]" < "$home/output" >> "$home/errors" grep "^5[0-9][0-9]" < "$home/output" >> "$home/errors" if [ -s errors ]; then /usr/bin/beep -f 1800 -l 200 -r 4 -d 500 echo "$1" >> "$targetfile" cat "$home/errors" >> "$targetfile" echo '' >> "$targetfile" notify-send -t 5000 "$1 is down!" rm "$home/output" "$home/errors" fi } function loopfile(){ while read line do checksite "$line" done < "$1" } while getopts s:f: options do case $options in f) loopfile $OPTARG;; s) checksite $OPTARG;; esac done