aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-08-03 22:54:07 +0200
committerMattias Andrée <maandree@kth.se>2016-08-03 22:54:07 +0200
commit5339ae417c20382f9ac9156d820e1d4e3cd85f46 (patch)
treeab94abbd8b7cccb98b50a9b40b312c9ba146b430
parentm (diff)
downloadmetar-5339ae417c20382f9ac9156d820e1d4e3cd85f46.tar.gz
metar-5339ae417c20382f9ac9156d820e1d4e3cd85f46.tar.bz2
metar-5339ae417c20382f9ac9156d820e1d4e3cd85f46.tar.xz
Update: the metar resources have moved1.2.2
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rwxr-xr-xmetar17
1 files changed, 14 insertions, 3 deletions
diff --git a/metar b/metar
index 9555025..5d66e7b 100755
--- a/metar
+++ b/metar
@@ -2,6 +2,17 @@
set -e
+
+metar_url ()
+{
+ url="http://tgftp.nws.noaa.gov/data/observations/metar/decoded"
+ if test $# = 1; then
+ echo "${url}/${1}.TXT"
+ else
+ echo "${url}/"
+ fi
+}
+
usage ()
{
echo "usage: $0 (get | print | set STATION | list [PREFIX] | closest [LATITUDE LONGITUDE] [LIST])"
@@ -49,14 +60,14 @@ list_stations ()
if test -z "$file"; then
exit 1
fi
- if ! curl -s "http://weather.noaa.gov/pub/data/observations/metar/decoded/" > "$file"; then
+ if ! curl -s "$(metar_url)" > "$file"; then
unlink "$file"
exit 1
fi
list="$(sed -n 's/^.*<a href="\('"$1"'[A-Za-z0-9]*\)\.TXT">.*$/\1/p' "$file")"
unlink "$file"
for icao in $list; do
- curl -s "http://weather.noaa.gov/pub/data/observations/metar/decoded/${icao}.TXT" | head -n 1
+ curl -s "$(metar_url "${icao}")" | head -n 1
done
}
@@ -101,7 +112,7 @@ EOF
}
if test $# = 1 && test "$1" = "get"; then
- curl -s "http://weather.noaa.gov/pub/data/observations/metar/decoded/$(get_station).TXT" || exit 1
+ curl -s "$(metar_url "$(get_station)")" || exit 1
elif test $# = 1 && test "$1" = "print"; then
get_station
elif test $# = 2 && test "$1" = "set"; then