[conspire] weather script

Calvin Wong deadcat at freeshell.org
Fri Apr 8 22:11:03 PDT 2005


i was working on a weather script for torsmo(1) today and came up with
something like this:

#!/bin/bash
#
#  Author       :  Calvin Wong <deadcat at freeshell.org>
#  File Name    :  tweather
#  Discription  :  parse the crappy weather from weather.yahoo.com
#  Comment(s)   :  this sucks really bad!!!
#  Created On   :  Fri Apr  8 14:45:26 PDT 2005
#  Last Modified:  $Id: tweather,v 1.1 2005/04/08 21:47:50 deadcat Exp $

#  default zip code is san francisco
#
zipcode=${1:-"94112"}
file=/tmp/weather.$$.txt
location="http://weather.yahoo.com/search/weather2?p=$zipcode"

# San Francisco Weather:
#    Currently: 59°
#    Mostly Cloudy/Windy
#    High: 55°
#    Low: 49°
# Tomorrow:
#    Low: 49°
#    Partly Cloudy/Wind
#    High: 58°
#
[ ! -f $file ] && lynx -accept_all_cookies -dump $location > $file || exit 100
grep "Weather$" $file | tail -n 1 | sed -e 's/^\ \+//' -e 's/$/:/'
echo -e "   Currently: \c"
sed -n '/Currently:$/,+1p' $file | tail -n 1 | sed 's/^\ \+//'
sed -n '/Currently:$/,+5p' $file | tail -n 3
echo "Tomorrow:"
sed -n '/Currently:$/,+18p' $file | tail -n 3 | sed 's/ sky:.\+//'
rm $file || exit 200

-- 
	But as records of courts and justice are admissible, it can
easily be proved that powerful and malevolent magicians once existed
and were a scourge to mankind.  The evidence (including confession)
upon which certain women were convicted of witchcraft and executed was
without a flaw; it is still unimpeachable.  The judges' decisions based
on it were sound in logic and in law.  Nothing in any existing court
was ever more thoroughly proved than the charges of witchcraft and
sorcery for which so many suffered death.  If there were no witches,
human testimony and human reason are alike destitute of value.
		-- Ambrose Bierce, "The Devil's Dictionary"




More information about the conspire mailing list