Skip to content

Instantly share code, notes, and snippets.

@codingtony
Created October 14, 2018 17:51
Show Gist options
  • Save codingtony/a48d2a8817513ee13596f6e8cf01d19c to your computer and use it in GitHub Desktop.
Save codingtony/a48d2a8817513ee13596f6e8cf01d19c to your computer and use it in GitHub Desktop.
Fetch Metar
#!/bin/bash
AIRPORT=$1
DATE=$2
TIME=$3
UTC=$(printf "TZ=UTC date +\"%%Y%%m%%d %%H%%M\" --date='TZ=\"America/Montreal\" %s %s'" $2 $3)
UTC=$(eval ${UTC})
#echo $UTC
Y=${UTC:0:4}
M=${UTC:4:2}
D=${UTC:6:2}
H=${UTC:9:2}
m=${UTC:11:2}
#echo $Y $M $D $H $m
URL=$(printf "http://www.ogimet.com/display_metars2.php?lang=en&lugar=%s&tipo=ALL&ord=REV&nil=SI&fmt=txt&ano=%s&mes=%s&day=%s&hora=%s&anof=%s&mesf=%s&dayf=%s&horaf=%s&minf=59&send=send" $AIRPORT $Y $M $D $H $Y $M $D $H)
#echo $URL
echo
elinks --dump "$URL" | egrep -v '^\s*#|^\s*$' | egrep 'METAR|SPECI' | sed 's/^[ \t]*//;s/[ \t]*$//' | sed 's/^[0-9]\{12\} //'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment