BTW, check your syntax; yyz / YYC
Doh!...Still no go
I searched around a little and found there are several weather scripts, none of which I could understand. So I thought I would waste some time and write my second ever bash script!
First I found you can use a text browser to dump an html file to a text file.
lynx -dump http://www.mysite.com/page.html > page.txt
This works fine except for RSS feeds which for some reason have html tags still intact in the dump. To get around this I dumped into an html file and then re-dumped into a text file.
lynx -dump http://text.weatheroffice.gc.ca/rss/city/on-69_e.xml > pageRSS.html
lynx -dump pageRSS.html > pageRSS.txt
Next I extracted and printed the lines I wanted (from some tutorial) with sed
sed -n 7,11p pageRSS.txt
and removed the dump files when no longer needed. so the whole thing looks like this.
#!/bin/bash
#script for weather from http://text.weatheroffice.gc.ca/rss
lynx -dump http://text.weatheroffice.gc.ca/rss/city/on-69_e.xml > pageRSS.html
lynx -dump pageRSS.html > pageRSS.txt
rm pageRSS.html
sed -n 7,11p pageRSS.txt
rm pageRSS.txt
fi
exit 0
There are a couple of obvious problems. I copied the ending off of another script and it throws an error
can2.sh: line 9: syntax error near unexpected token `fi'
can2.sh: line 9: `fi'
Second If there is a weather warning above line 7 in my txt file I will be printing the wrong lines.
I would also like to shave 5 characters off of the first line for formatting the output.