Getting your local weather forcast with your Eee
April 10, 2008
This little tidbit of code will display a weather forecast for whatever zipcode you put in (US Only).
Just copy/paste the code between the lines into an editor (vi, vim, nano, whatever!) and save it as weather.sh – then type chmod 766 weather.sh
It does rely on lynx, so, you may need to install that ahead of time.
( yum install lynx or apt-get install lynx )
============================================================
#!/bin/sh
# weather – report weather forecast, including lat/long, for zip
llurl=”http://www.census.gov/cgi-bin/gazetteer?city=&state=&zip=”
wxurl=”http://wwwa.accuweather.com”
wxurl=”$wxurl/adcbin/public/local_index_print.asp?zipcode=”
if [ "$1" = "-a" ] ; then
size=999; shift
else
size=5
fi
if [ $# -eq 0 ] ; then
echo “Usage: $0 [-a] zipcode” >&2
exit 1
fi
if [ $size -eq 5 ] ; then
echo “”
# get some information on the zipcode from the Census Bureau
lynx -source “${llurl}$1″ | \
sed -n ‘/^<li><strong>/,/^Location:/p’ | \
sed ’s/<[^>]*>//g;s/^ //g’
fi
# the weather forecast itself at accuweather.com
lynx -source “${wxurl}$1″ | \
sed -n ‘/Start – Forecast Cell/,/End – Forecast Cell/p’ | \
sed ’s/<[^>]*>//g;s/^ [ ]*//g’ | \
uniq | \
head -$size
exit 0
============================================================


It’s quick, fast, and doesn’t use any resources. Just what one needs for the Eee!
Have fun… well, as much fun as you can have looking up forecasts, populations, and what not…
By the way, don’t copy the === lines… those are just there to break up the code from the content.
eeeWeather works quite well with a nice tray icon. Author says it works with any QT-4 Compliant taskbar.