Twitter bot weatherlisbon
This one returns daily weather forecasts for Lisbon city based on the BBC weather forecast rss feed.
1 2 #! /bin/sh 3 4 #Goto here 5 here=/home/guillaume/Personal 6 cd $here 7 8 #BBC Lisbon weather id 9 id=0048 10 11 #BBC weather RSS feed address 12 feed="http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/${id}.xml" 13 14 #City 15 city=lisbon 16 17 #temporary file 18 file="weather${city}" 19 20 #Weather twitter bot 21 twitbot=weatherlisbon:******* 22 23 #Timestamp the log file 24 echo .>> $file.log 25 date >> $file.log 26 27 #Read the RSS feed and filter it 28 curl $feed | grep 'title' | tail -n 1 | perl -wlne'm/title>(.*)<\/title/i && print $1' | sed -e "s/°//g" > $file.txt 29 30 #Read the forecast into a weather variable 31 read weather < $file.txt 32 33 #Twit the weather variable away 34 curl --basic --user $twitbot --data status="$weather" http://twitter.com/statuses/update.xml >> $file.log