Woot Bash Script
Here’s a SIMPLE bash script I cooked up for checking woot deals. It is has
been running for a whopping 5 hours (still no darned wootoff!) so you
might say it’s in very early Alpha. I set mine up in Ubuntu (which is
basically identitical to Debian for the purposes of this little
script.) I know there are fine folks out there that do this via
registration, but I really wanted keep my phone number OFF the Internet
(call me a paranoid freak–don’t worry…I will agree.)
I thought I might as well pass this on. Please, this comes with ABSOLUTELY no
warranties WHATSOEVER. Use at your own risk! Also, don’t criticize my
bash scripting, just make it better and post it or keep it to yourself.
Again, this is the product of a few minutes scripting (very basic but
works for me so far.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #! /bin/sh #-------------------------------------------------------------------------------- # chkwoot.sh # Woot Notifier Script by Brett Millett 2006 # Requirements/Dependencies: curl, awk, mailutils (ubuntu) # This setup works nice in Ubuntu with the ssmtp package which let's me # forward emails to my LAN mailhub (or ISP mailhub.) # In Debian/Ubuntu: sudo apt-get install curl mailutils ssmtp # Other distros: Get binaries and alter paths accordingly. #-------------------------------------------------------------------------------- ACCOUNTS=( you@yourdomain.tld ) FILE=/tmp/wootstate CONTENT=`/usr/bin/curl -s -f http://www.woot.com/DefaultMicrosummary.ashx` HOUR=$(date +"%H"); #echo $HOUR # remove leading white spaces CONTENT=${CONTENT## } # remove trailing white spaces CONTENT=${CONTENT%% } touch FILE if [ -n "$CONTENT" ]; then PRICE=`echo $CONTENT |/usr/bin/cut -s -d':' -f1` PRODUCT=`echo $CONTENT |/usr/bin/cut -s -d':' -f2` STATUS=`echo $CONTENT |/usr/bin/cut -s -d':' -f3` LASTCHAR=${PRICE#${PRICE%?}} #echo $LASTCHAR if [ "$LASTCHAR" == "%" ]; then PERCENT=$PRICE PRICE=$PRODUCT PRODUCT=$STATUS STATUS=`echo $CONTENT |/usr/bin/cut -s -d':' -f4` fi if [ -n "$PRODUCT" ]; then OLDHASH=`< $FILE` NEWHASH=`/bin/echo $CONTENT | /usr/bin/md5sum | /usr/bin/awk '{print $1}'` if [ "$OLDHASH" != "$NEWHASH" ]; then for EMAIL in ${ACCOUNTS[@]}; do /bin/echo "$CONTENT" | /usr/bin/mail -s "Woot" $EMAIL done fi /bin/echo $NEWHASH > $FILE fi fi |