Wednesday, November 09, 2011

 

Monitor a Woot-Off! Bash Script

Here is a simple script to monitor the Woot site, when a 'Woot-Off' is underway. The script can easily be customized to perform a similar function for any desired site. I use it under Cygwin on Windows, and when the Woot site is updated, a 'bell' is sounded, so that if I'm by this machine, I can take a look to see if the new item is the elusive 'bag of crap'! (So far no success - you need to be fast or lucky).

The script waits 30 seconds + a random number of seconds between 0 and 60 prior to its visits to the Woot site. The sound creation step is customized for Cygwin, if you are on Linux or a Mac, just use:
echo -en "\007"
(or something similar).



#!/bin/sh

while true
do
wget -O - "http://www.woot.com/" | \
grep "meta property=\"og:title\" content=" \
> tmp.txt
diff tmp.txt tmpold.txt > /dev/null
ret=$?
if [ $ret -eq 0 ]
then
echo "NO CHANGES"
echo "Current item"
cat tmp.txt
else
echo "CHANGES!"
cat `cygpath -W`/Media/ding.wav > /dev/dsp
cp tmp.txt tmpold.txt
fi
SLEEP=`awk 'BEGIN{srand(); print int(rand()*60+30)}'`
echo "Sleeping for " $SLEEP " seconds"
sleep $SLEEP
done
Comments: Post a Comment



<< Home
Newer Posts Older Posts