- Most Recent |
24 hours |
7 days |
30 days |
365 days |
HowFlow —
Little script which retrieve weather information on your console. Forget vista sidebar ;)
Posted by
lied 8 months ago
lied 8 months ago If you ever asked yourself if it possible to get the temperature outside without google or going to the window – here is a solution:
Simple look up which Airport ist next to you.
For example Nuremberg is EDDN.
Usage: weather stationID
weather EDDN
Retrieving information for EDDN:
date: 2008.04.28 1850 UTC
temp: 13 degree Celcius / 55 degree Fahrenheit
Put the code in your ~/.zshrc. It creates a new function with the name “weather”.
( You can also put this in /usr/local/bin/weather have a look at http://howflow.com/pastes/42 )
weather() {
[[ -n "$1" ]] || {
print 'Usage: weather <station_id>' >&2
return 1
}
local PLACE="${1:u}"
local FILE="$HOME/.weather/$PLACE"
local LOG="$HOME/.weather/log"
[[ -d $HOME/.weather ]] || {
print -n "Creating $HOME/.weather: "
mkdir $HOME/.weather
print 'done'
}
print "Retrieving information for ${PLACE}:"
print
wget -T 10 --no-verbose --output-file=$LOG --output-document=$FILE --timestamping http://weather.noaa.gov/pub/data/observations/metar/decoded/$PLACE.TXT
if [[ $? -eq 0 ]] ; then
if [[ -n "$VERBOSE" ]] ; then
cat $FILE
else
DATE=$(grep 'UTC' $FILE | sed 's#.* /##')
TEMPERATURE=$(awk '/Temperature/ { print $4" degree Celcius / " $2" degree Fahrenheit" }' $FILE| tr -d '(')
echo "date: $DATE"
echo "temp: $TEMPERATURE"
fi
else
print "There was an error retrieving the weather information for $PLACE" >&2
print "For example Nuremberg is EDDN"
print "more places: http://en.wikipedia.org/wiki/List_of_airports_by_ICAO_code:_E"
cat $LOG
rm $HOME/.weather/$PLACE
return 1
fi
}
Please log in or sign up and vote for this trick if it was helpful for you.
Don't forget to subscribe to our
RSS/Atom feed to get the latest tricks.
Don't forget to subscribe to our
RSS/Atom feed to get the latest tricks.









