Last active
May 19, 2017 14:43
-
-
Save billerby/dd5ade07012e017cd014da2ae580464b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
result=$(curl -sS http://holfuy.com/clientraw/s155/clientraw.txt) | |
set -f | |
variables=(${result//:/ }) | |
current_wind_knots=${variables[1]} | |
gust_knots=${variables[2]} | |
degrees=${variables[3]} | |
temp=${variables[4]} | |
current_wind_ms=$(bc <<< "scale=2;($current_wind_knots * 0.51444444444)/1") | |
echo "current wind ms: $current_wind_ms" | |
echo "gust_knots: $gust_knots" | |
echo "Wind degrees: $degrees" | |
val=$(bc <<< "scale=0;($degrees/22.5)+0.5") | |
valRounded=$(echo $val | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}') | |
windDirections=(N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW) | |
index=($valRounded % 16) | |
echo "Wind direction: ${windDirections[$index]}" | |
echo "temperature: $temp" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment