Created
May 27, 2014 15:33
-
-
Save Profpatsch/675e95243fdf064c4f3c to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Takes recipient as first and URL to watch as second argument. | |
# Will create a file in the folderto compare the last state | |
# with the current one. | |
RECIPIENT=$1 | |
URL=$2 | |
FILENAME=$(echo "$URL" | sed -e 's,/,*,g') | |
if [ ! -e "$FILENAME" ]; then | |
curl "$URL" > "$FILENAME" | |
fi | |
curl "$URL" > "$FILENAME.new" | |
DIFF=$(diff -u "$FILENAME" "$FILENAME.new") | |
[ $? -ne 0 ] && echo sent && \ | |
sendmail -t <<EOF | |
To: $RECIPIENT | |
From: url-watcher | |
Subject: $URL has changed. | |
"$DIFF" | |
EOF | |
mv "$FILENAME.new" "$FILENAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment