Commit | Line | Data |
---|---|---|
1 | #! /bin/sh | |
2 | ||
3 | set -e | |
4 | ||
5 | weather_station_id="$1" | |
6 | ||
7 | metar -d "$weather_station_id" 2>&1 \ | |
8 | | awk ' | |
9 | /METAR pattern not found in NOAA data/ { | |
10 | failures++ | |
11 | } | |
12 | ||
13 | /^Temperature/ { | |
14 | celsius = $3; | |
15 | fahrenheit = (celsius * (9 / 5)) + 32; | |
16 | temperature = fahrenheit | |
17 | } | |
18 | ||
19 | END { | |
20 | if (failures > 0) { | |
21 | temperature = "--" | |
22 | } | |
23 | print temperature "°F" | |
24 | }' |