Get current METAR and/or TAF report
authorDan White <dan@whiteaudio.com>
Fri, 16 Sep 2011 03:50:54 +0000 (22:50 -0500)
committerDan White <dan@whiteaudio.com>
Fri, 16 Sep 2011 03:50:54 +0000 (22:50 -0500)
metar.sh

index f027381a07a223db6b5049da17ad5f171d49f83c..bd142bcec309deacc0d0c6a0e318e3e3ef5940f6 100755 (executable)
--- a/metar.sh
+++ b/metar.sh
@@ -1,7 +1,31 @@
 #!/bin/bash
 
+
+METAR=1
+TAF=1
+if [ "$1" == "-m" ]; then
+    METAR=1
+    TAF=0
+    shift
+elif [ "$1" == "-t" ]; then
+    METAR=0
+    TAF=1
+    shift
+fi
+
 STATION=$1
 
-wget -q -O - http://weather.noaa.gov/mgetmetar.php?cccc=$STATION \
-    | grep -i $STATION \
-    | tail -1
+if [ $METAR -eq 1 ]; then
+    # METAR
+    wget -q -O - http://weather.noaa.gov/mgetmetar.php?cccc=$STATION \
+        | grep -i $STATION \
+        | tail -1
+fi
+
+if [ $TAF -eq 1 ]; then
+    # TAF
+    wget -q -O - http://weather.noaa.gov/cgi-bin/mgettaf.pl?cccc=$STATION \
+        | awk '/<pre>/, /<\/pre>/ { print }' \
+        | sed -e 's/<[/]*\w\+>//g' -e 's/^ \+/  /g'
+fi
+