Sometimes, like today, I'm particularly interested in the Apple Store's status...as in, when is it back up so that I can order whatever it is I'm waiting to order. While sitting around pressing Command-R this morning, I figured there must be a better way. After a few minutes with curl and GeekTool, I had the solution.
Because I didn't have very much time to implement this trick this morning, I just created a new 'Shell' Geeklet in GeekTool, with the refresh set to every five seconds, that showed the output of this command:
curl -s http://store.apple.com/us | grep backsoon | grep australia
Note that the above is specific both to the US Apple Store, and to the current version of that store. You may have to modify it for other geographies, or for future store site changes. Basically, what the command does is grab the Apple Store page via curl, suppresses the normal output (-s), and then searches for backsoon, which is the name of the GIF image Apple uses for the "We'll be back soon!" graphic.
There are, however, lots of matches for backsoon, so I then grep again for australia, which was the first occurrence of backsoon in the output. This way, I get just one line of output when the store is down. When it's up, there shouldn't be any output.
Testing was real world, too, as I waited for the 5:30am scheduled store opening. About a minute before that, the output from my Geeklet suddenly went blank, so I reloaded the web page, and there was the store. Nifty. For longer-term use, though, my solution leaves much to be desired. So after ordering the iPad, I turned my quick solution into a slightly more robust script that uses Growl to put the alert onscreen. Read on for that version.
I created the following script, which I named storecheck, in my user's bin folder:
#! /bin/bash MYVAR=`curl -s http://store.apple.com/us | grep backsoon | grep australia` if [ "$MYVAR" = "" ] then if [ ! -f "/tmp/storeup.txt" ]; then growlnotify "The Store is up!" -m "Go buy whatever it was you were waiting for!" echo "1" > /tmp/storeup.txt fi fi
Mac OS X Hints
http://hints.macworld.com/article.php?story=20100312062238261