#!/bin/sh -
PATH=$PATH:/l/palm/bin

urls='http://weather.noaa.gov/cgi-bin/iwszone?Sites=:miz075'

title='Weather Report'
dest="${PALMINST-$HOME/l/palm/install}/weather.pdb"

# clipweather - personalized Palm web clipper for local weather report
# Steve Kinzler, steve@kinzler.com, Dec 99
# https://kinzler.com/me/home.html#palm

case "$#" in
0)	;;
*)	echo "usage: $0" 1>&2; exit 1;;
esac

tmpA=/tmp/cwA$$
tmpB=/tmp/cwB$$
trap "rm -f $tmpA $tmpB; exit" 0 1 2 13 15

for url in $urls
do
	lynx -dump -nolist "$url"
done > $tmpA
grep '^lynx: ' $tmpA && exit $?

sed '1,/^MIZ/d
     s/\[[^\]]*\]//g
     s/	/ /g; s/  */ /g; s/ *$//
     /following information has EXPIRED/,/previous information has EXPIRED/d
     /^MIZ/d
     /^ /d
     /FORECAST/s/$/ --------/
     /ROUNDUP/,$d' < $tmpA | gnu cat -s > $tmpB

test -s $tmpB || { echo "$0: empty report" 1>&2; exit 2; }

txt2pdbdoc "$title" $tmpB "$dest"
