Shell Scripting: Get METARs & TAFs from “aviationweather.gov” and “weather.noaa.gov”

This small script is what I use to get METARs and TAFs for my preferred stations from aviationweather.gov or weather.noaa.gov WebSite (data is displayed by GeekTool on my iMac desktop).

To have latest METAR from weather.noaa.gov:

curl --silent \
http://weather.noaa.gov\
/pub/data/observations/metar/stations/LIRZ.TXT \
| sed -n '2p'

Notes:
“LIRZ” is “Perugia S. Egidio” Station (nearest station from my house). This ICAO Airport Identifier has to be changed with the desired one.
The use of sed in this small script is necessary to display only the second line of the report file. If you don’t need to remove METAR extended publication date from your GET, you don’t need to parse curl result, just print the entire content of the .TXT file.

To have latest METAR and TAF form aviationweather.gov:

curl --silent \
"http://aviationweather.gov/adds/metars/index.php\
?station_ids=LIRZ\
&chk_metars=on\
&chk_tafs=on\
&std_trans=standard\
&submit=1"\
 | sed -e 's/]*>//g'\
 | egrep -o \("[A-Z]{4} [0-9]{6}Z.+"\|"    *[A-Z0-9]{3}.+"\)

Notes:
“LIRZ” is “Perugia S. Egidio” Station (nearest station from my house). This ICAO Airport Identifier has to be changed with the desired one.
The use of sed and egrep in this small script is necessary to remove HTML Tags and to display only bulletin data.
It is possible to specify multiple ICAO identifiers, separated by commas (Ex.: ?station_ids=LIRQ,LIRZ,LIRV).

Here is the result I’m obtaining with this piece of code (blitzortung.org image is part of another HTTP GET) and GeekTool:

The use of a MonoSpace Font is suggested to preserve original structure and improve readability.


Comments are closed.