Use __VA_ARGS__ instead of named param
[khatus.git] / x1 / bin / khatus_update_weather
CommitLineData
a4ecb5bc
SK
1#! /bin/bash
2
3set -e
4
5STATION_ID="$1" # ICAO designator. e.g. KJFK, KBOS
6
7FILE_METAR_DECODED="$HOME/var/run/metar-${STATION_ID}-decoded"
8FILE_TEMP_FAHRENHEIT="${FILE_METAR_DECODED}-temp-fahrenheit"
9FILE_TEMP_CELSIUS="${FILE_METAR_DECODED}-temp-celsius"
10
11(metar -d "$STATION_ID" 2>&1) > $FILE_METAR_DECODED # TODO: Better error handling
12
13awk \
14 -v file_fahrenheit="$FILE_TEMP_FAHRENHEIT" \
15 -v file_celsius="$FILE_TEMP_CELSIUS" \
16 '
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) {
28 print "--" > file_fahrenheit
29 print "--" > file_celsius
30 } else {
31 print fahrenheit > file_fahrenheit
32 print celsius > file_celsius
33 }
34 }' \
35 $FILE_METAR_DECODED
This page took 0.035154 seconds and 4 git commands to generate.