Created
September 21, 2011 21:55
-
-
Save brokaw/1233436 to your computer and use it in GitHub Desktop.
Monitor the Last-Modified HTTP header on www.aclfestival.com. Designed for Mac OS X.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# $1 = recipient | |
# $2 = The Subject | |
# $3 = The message content | |
sendapplemail() { | |
/usr/bin/osascript >/dev/null 2>&1 <<EOF | |
tell application "Mail" | |
set myContent to quoted form of "$3" | |
set theMessage to make new outgoing message with properties {subject:"$2", content:myContent, sender:"Steve Brokaw <[email protected]>"} | |
tell theMessage | |
make new to recipient at end of to recipients with properties {address:"$1"} | |
end tell | |
set theResult to send theMessage | |
end tell | |
EOF | |
} | |
updatetime() { | |
curl -A 'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201' -sI http://www.aclfestival.com | sed -n 's/^Last-Modified\:\ \(.*$\)/\1/p' | |
} | |
LAST_UPDATED=$(updatetime) | |
echo -n "Starting to check at: " | |
date -u | |
echo "Last updated: ${LAST_UPDATED}" | |
PREVIOUS_UPDATE=$LAST_UPDATED | |
while true | |
do | |
if [[ $PREVIOUS_UPDATE != $LAST_UPDATED ]] | |
then | |
echo "^GChange Detected: $LAST_UPDATED" | |
say "ACL website change detected" & | |
PREVIOUS_UPDATE=$LAST_UPDATED | |
CONTENT=$(curl -s http://www.aclfestival.com | grep -C 2 Souvenir | sed 's/\"//g') | |
if [[ ! $CONTENT =~ "Coming Soon" ]] | |
then | |
sendapplemail "##########@txt.att.net" "ACL HIGH ALERT!" "Check www.aclfestival.com NOW!" & | |
sendapplemail "[email protected]" "ALERT aclfestival.com was updated $LAST_UPDATED" "$CONTENT" & | |
else | |
sendapplemail "[email protected]" "aclfestival.com was updated $LAST_UPDATED" "$CONTENT" & | |
fi | |
fi | |
sleep 60 | |
LAST_UPDATED=$(updatetime) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment