Skip to content

Instantly share code, notes, and snippets.

@rcrowley
Created July 18, 2013 15:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcrowley/6030063 to your computer and use it in GitHub Desktop.
Save rcrowley/6030063 to your computer and use it in GitHub Desktop.
How to get a reservation at State Bird Provisions
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