I am trying to automate downloading our weather data for our school. I'm not a huge tech guy but I'm the best at the school I suppose. My problem is trying to insert the time variables into the web address. Here is what I have done so far.
Currently This works:
curl -o /Library/Server/Web/Data/Sites/wupmooksgmol.ca/weather/"$(date +%Y)"/"$(date +%Y-%m-%d)".weather.csv 'http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=IBRITISH322&day=16&month=1&year=2015&graphspan=day&format=1'
But, in the web address, it is only downloading the Jan. 16th 2015 weather data. I want to put in the current day, month and year into the web address itself. Thus, at 23:57 each day it downloads the weather data for that day. I have tried many variation on the following but no luck:
curl -o /Library/Server/Web/Data/Sites/wupmooksgmol.ca/weather/"$(date +%Y)"/"$(date +%Y-%m-%d)".weather.csv 'http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=IBRITISH322&day=“$(date +%d)”&month=“$(date +%m)”&year=“$(date +%Y)”&graphspan=day&format=1'
I have also attempted a numerous variations on this shell script:
#!/bin/bash
day=$(date '+%d')
month=$(date '+%m')
year=$(date '+%Y')
ymd=$(date '+%Y-%m-%d')
curl -o /Library/Server/Web/Data/Sites/wupmooksgmol.ca/weather/“$year"/"$ymd".weather.csv 'http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=IBRITISH322&day=“$day”&month=“$month”&year=“$year”&graphspan=day&format=1'
Thanks for any help you can provide.