Add missing option spec
[khatus.git] / bin / khatus_update_weather
CommitLineData
756b9d5a
SK
1#! /bin/bash
2
3set -e
4
69f6cba9
SK
5STATION_ID="$1" # ICAO designator. e.g. KJFK, KBOS
6
7FILE_METAR_DECODED="$HOME/var/run/metar-${STATION_ID}-decoded"
756b9d5a 8FILE_TEMP_FAHRENHEIT="${FILE_METAR_DECODED}-temp-fahrenheit"
69f6cba9 9FILE_TEMP_CELSIUS="${FILE_METAR_DECODED}-temp-celsius"
756b9d5a 10
69f6cba9 11(metar -d "$STATION_ID" 2>&1) > $FILE_METAR_DECODED # TODO: Better error handling
756b9d5a 12
69f6cba9
SK
13awk \
14 -v file_fahrenheit="$FILE_TEMP_FAHRENHEIT" \
15 -v file_celsius="$FILE_TEMP_CELSIUS" \
16 '
756b9d5a
SK
17 /METAR pattern not found in NOAA data/ {
18 failures++
19 }
20
21 /^Temperature/ {
22 celsius = $3;
23 fahrenheit = (celsius * (9 / 5)) + 32;
24 }
25
26 END {
27 if (failures > 0) {
69f6cba9
SK
28 print "--" > file_fahrenheit
29 print "--" > file_celsius
756b9d5a 30 } else {
69f6cba9
SK
31 print fahrenheit > file_fahrenheit
32 print celsius > file_celsius
756b9d5a
SK
33 }
34 }' \
69f6cba9 35 $FILE_METAR_DECODED
This page took 0.029576 seconds and 4 git commands to generate.