tweather - scripts - various script and utils
HTML git clone git://z3bra.org/scripts
DIR Log
DIR Files
DIR Refs
---
tweather (736B)
---
1 #!/bin/sh
2 #
3 # z3bra - (c) wtfpl 2014
4 # fetch weather and temperature using openweathermap API
5
6 CITY=${1:-aix-en-provence}
7 FORECAST=${FORECAST:-5}
8 UNITS=${UNITS:-metric}
9
10 URL="http://api.openweathermap.org/data/2.5/forecast/daily/?q=$CITY&cnt=$FORECAST&mode=xml&units=$UNITS"
11
12 curl -s "$URL" | sed -e 's/.*time day="\([^" ]*\).*/\1,/p' \
13 -e 's/^.*symbol.*name="\([^"]*\).*$/\1,/p' \
14 -e 's/^.*temperature.*day="\([^"]*\).*$/\1°C/p'\
15 -e 'd' \
16 | paste -d "" - - - \
17 | sed 's/^\(.*\),\(.*\),\(.*\)/\1,\3,\2/' \
18 | column -t -s, -o" - "