Weather Check

If you have a linux OS the bash shell script below will tell you most recent temp, windspeed, direction, and rainfall at Everton, Sandy, and Biggleswade from local weather stations using weatherunderground. I crontab it, piping the results to mail -s ‘Current weather’ sock@madeup.com

 #!/bin/bash

function checkComponent() {

         aurl='http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID='$1'&theprefset=WXSTNDEL&theprefvalue=0&format=1'
       name=$2
       curl -s $aurl | tail -3 | tr '\n' ',' | awk -F, ' { print "NAME@ " (5/9)*($2-32) "C dp " (5/9)*($3-32) "C " $5 "@" $8 "mph " $92 "CurrentRain " $10 "in DailyRain " $13 "in\n" } ' | sed "s:NAME:${name}:" >> tempweather
 }

checkComponent IENGLAND82 Everton
checkComponent IBEDSBIG1 Biggles
checkComponent I90580822 Sandy

cat tempweather
rm tempweather

Advertisements