#!/bin/sh # grabweather.sh v.1.0.1 22 October 2006 # Copyright 2006 Steven Lucy slucy@uchicago.edu # Released under the GPL v. 2 # This is a helper script for showweather.pl. It should be run on the hour # and half-hour from cron (or just hourly if you prefer). Find out when your # source files update and grab soon after. # Most of the changes to make this not Chicago-specific will take place in this file. cd /var/www/weather #curr obs in XML! :) wget -q -T 5 --tries=2 -O KMDW.xml 'http://www.weather.gov/data/current_obs/KMDW.xml' wget -q -T 5 --tries=2 -O KSFO.xml 'http://www.weather.gov/data/current_obs/KSFO.xml' wget -q -T 5 --tries=2 -O KBOS.xml 'http://www.weather.gov/data/current_obs/KBOS.xml' wget -q -T 5 --tries=2 -O KNEW.xml 'http://www.weather.gov/data/current_obs/KNEW.xml' wget -q -T 5 --tries=2 -O KUNV.xml 'http://www.weather.gov/data/current_obs/KUNV.xml' chmod 644 *.xml #forecast in HTML wget -q -T 5 --tries=2 -O mdw.forecast http://www.crh.noaa.gov/lot/lfp.php wget -q -T 5 --tries=2 -O sfo.forecast 'http://www.wrh.noaa.gov/mtr/getzfpzone.php?sid=mtr&zone=caz006' wget -q -T 5 --tries=4 -O bos.forecast 'http://www.erh.noaa.gov/box/displayazone.php?version=0&zonecode=MAZ015' wget -q -T 5 --tries=4 -O new.forecast 'http://weather.noaa.gov/cgi-bin/iwszone?Sites=:laz062' wget -q -T 5 --tries=4 -O unv.forecast 'http://weather.noaa.gov/pub/data/forecasts/zone/pa/paz019.txt' chmod 644 *.forecast # This part is ugly, and taken from when this entire thing was implemented # in shell scripts (!) on a server with no CGI support. Ick! Could be cleaned # up and made perltastic. # # Seriously, it's probably easier to write it from scratch than to figure out # what the hell I was doing below (though it seems to work...): #a=`head -n \`grep -n 'End' lfp.php | cut -f1 -d:\` lfp.php | wc -l` #b=`head -n \`grep -n 'End' lfp.php | cut -f1 -d:\` lfp.php | grep -n '^CHICAGO METR' | cut -f1 -d:` #c=$(($a - $b)) # #echo "
" > insert.html
#
#head -n `grep -n 'End' lfp.php | cut -f1 -d:` lfp.php | tail -n $c | tr [A-Z] [a-z] | sed -e 's,^\.,
#
,' | sed -e 's,>\([^.]*\)\.\.\.,>\1...,' | sed -e 's,\.\.\.$,...,' | grep -v '$$' | grep -v 'pre>' >> insert.html
#
#echo "