#!/bin/sh # Snazzy Weather server script v0.2 # As of writing, the script only runs early in the morning # to get the morning version of the NOAA weather data, # since the afternoon/evening report does not include # morning data. I'll eventually make a version that # keeps things more up to date. Probably. # I have this script set to run via crontab -e # Example to put in cron job file on your server: # cd /home/user; ./getweather.sh > finalweather.txt # Snazzy weather then downloads http://old.jojo2k.com/finalweather.txt # for its weather data. # Go here for more info about the NOAA/NWS weather API and find your own location # https://www.weather.gov/documentation/services-web-api curl https://api.weather.gov/gridpoints/OUN/XX,XX/forecast > rawweather.txt wfile="rawweather.txt" # High temperature for current day sed -n 57p $wfile | grep -Eo '[+-]?[0-9]{1,4}' # Wind speed for current day - can either be formatted by NOAA as number OR x to x mph sed -n 64p $wfile | cut -d: -f2 | grep -o '"[^"]\+"' | sed 's/"//g' # Wind direction sed -n 65p $wfile | cut -d: -f2 | grep -o '"[^"]\+"' | sed 's/"//g' # Conditions for current day sed -n 67p $wfile | cut -d: -f2 | grep -o '"[^"]\+"' | sed 's/"//g' # Low temperature for current day sed -n 76p $wfile | grep -Eo '[+-]?[0-9]{1,4}' # High temperature for next day sed -n 95p $wfile | grep -Eo '[+-]?[0-9]{1,4}' # Low temperature for next day sed -n 114p $wfile | grep -Eo '[+-]?[0-9]{1,4}' # Detailed conditions for current day sed -n 68p $wfile | cut -d: -f2 | grep -o '"[^"]\+"' | sed 's/"//g'