From afc7689e9654c81cb65f3afe3088c3df7e3656d9 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 13 Feb 2023 12:12:47 +0000 Subject: Initial commit. --- metar.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 metar.sh diff --git a/metar.sh b/metar.sh new file mode 100755 index 0000000..88b3ff4 --- /dev/null +++ b/metar.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +read ICAO + +if ! echo "$ICAO" | grep -Eq "^([A-Z]|[a-z]){4}$" ; then + echo "error: invalid ICAO code!" + exit 1 +fi + +xmllint --xpath 'string(/response/data/METAR/raw_text)' <(curl -s "https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=$ICAO&hoursBeforeNow=1") | head -n1 + -- cgit v1.2.3