iPhone and Linux

Sunday, April 19, 2009

Nice script

This is a pretty sweet script for any linux weather geeks. it downloads a base reflectivity radar map from the National Weather Service and notifies you if there is any precipitation within x miles of your location.

I've actually been looking for this forever because we have to bring things inside at work when it starts to rain, plus I often have the top down on my Jeep and want a little warning if it's going to rain.

I had problems with stateMon.pl so I wrote a simple script to run the other scripts and handle the notification.

(rewritten to a much better looking script Jan 2010)
#! /bin/sh

wget -q http://radar.weather.gov/ridge/RadarImg/N0R/MRX_N0R_0.gif

current=$(perl ./getprecipstate.pl MRX_N0R_0.gif 226 314 20 20 | awk '{ print $3 }')
old=$(tail -n 1 record | awk '{ print $7 }')

[ $current = 'raining' ] && [ $old = 'clear' ] && add your notification method here

echo -n `date` >> record ; echo " $current" >> record ; rm MRX_N0R*
That script is set up as a cron job and it will send a txt message to my phone whenever any precipitation shows up on radar within 10 miles of my home. Pretty cool!

Blog Archive