Created
July 18, 2013 15:04
How to get a reservation at State Bird Provisions
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
set -e | |
mail() { | |
echo "$@" | | |
/usr/bin/mail -a"From: Richard Crowley <r@rcrowley.org>" -s"State Bird Provisions" "1234567890@vtext.com" | |
echo "$(date): there was a reservation!" >&2 | |
} | |
TMP="$(mktemp)" | |
trap "mail \"FAILURE\"; rm -f \"$TMP\"" EXIT INT QUIT TERM | |
while true | |
do | |
curl -sv "http://rez.urbanspoon.com/reservation/start/2086" >"$TMP" 2>&1 | |
if ! grep -q "Unfortunately, there are no web reservations available for this restaurant at this time." "$TMP" | |
then mail "http://rez.urbanspoon.com/reservation/start/2086" | |
fi | |
if ! grep -q "HTTP/1.1 200 OK" "$TMP" | |
then mail "$(grep "^< HTTP/1.1" "$TMP" | cut -c"3-")" | |
fi | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment