1 # retrieve weather information on the console
2 # Usage example: 'weather LOWG'
7 print 'Usage: weather <station_id>'
9 'List of stations: http://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code'
13 local VERBOSE="yes" # TODO: Make this a command line switch
17 local DIR="${HOME}/.weather"
18 local LOG="${DIR}/log"
20 if [[ -d ${DIR} ]]; then
21 print -n "Creating ${DIR}: "
26 print "Retrieving information for ${PLACE}:"
29 wget -T 10 --no-verbose --output-file=$LOG --timestamping \
30 http://weather.noaa.gov/pub/data/observations/metar/decoded/$PLACE.TXT
32 if [[ $? -eq 0 ]]; then
33 if [[ -n "$VERBOSE" ]] ; then
36 DATE=$(grep 'UTC' ${PLACE}.TXT | sed 's#.* /##')
37 TEMPERATURE=$(awk '/Temperature/ {
38 print $4" degree Celcius / " $2" degree Fahrenheit"
39 }' ${PLACE}.TXT | tr -d '(')
41 echo "temp: $TEMPERATURE"
44 print "There was an error retrieving the weather information for $PLACE" >&2