Skip to content

Instantly share code, notes, and snippets.

@ohazi
Created November 13, 2014 21:24
Show Gist options
  • Save ohazi/bf2dd60cd80f9ecd03e3 to your computer and use it in GitHub Desktop.
Save ohazi/bf2dd60cd80f9ecd03e3 to your computer and use it in GitHub Desktop.
Send yourself an SMS when Nexus 6 is in stock
#!/bin/bash
N6_BLUE_64="https://play.google.com/store/devices/details/Nexus_6_64GB_Midnight_Blue?id=nexus_6_blue_64gb"
while true
do
n6_blue_data=$(wget $N6_BLUE_64 -O - 2> /dev/null)
sanity_check=$(echo $n6_blue_data | wc -c)
if [ $sanity_check -le 50000 ]
then
echo "Sanity check failed"
sleep 20
continue
fi
out_of_stock=$(echo $n6_blue_data | grep "out of inventory" | wc -l)
if ([ $out_of_stock -eq 0 ])
then
echo "In stock"
dummy=$(curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/[your twilio SID]/Messages.json' --data-urlencode 'To=[your cell phone number]' --data-urlencode 'From=[your twilio phone number]' --data-urlencode 'Body=Blue 64GB Nexus 6 is in stock' -u [your twilio SID]:[your twilio auth key])
exit
else
echo "Out of stock"
fi
sleep 20
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment