Skip to content

Instantly share code, notes, and snippets.

@jasonhancock
Created December 31, 2015 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonhancock/961c4cd5029332a1728e to your computer and use it in GitHub Desktop.
Save jasonhancock/961c4cd5029332a1728e to your computer and use it in GitHub Desktop.
#!/bin/bash
ADDR='email@example.com'
PRODUCT_ID=2885
TMP_FILE=/tmp/adafruit.tmp
wget -O $TMP_FILE -q https://www.adafruit.com/product/$PRODUCT_ID > /dev/null 2>&1
TS=`date '+%Y-%m-%d %H:%M:%S'`
if [[ $? != 0 ]]; then
echo "$TS error downloading file"
exit 1
fi
grep -i "OUT OF STOCK" $TMP_FILE > /dev/null 2>&1
if [[ $? != 0 ]]; then
echo "$TS sending mail"
echo "adafruit in stock" | mail -s "adafruit in stock" $ADDR
else
echo "$TS not sending mail"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment