DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Curl Magic
// using curl to upload files, update twitter status
#! /bin/sh
# Update twitter
# curl --basic --user username:password --data status="Having fun with cURL" http://twitter.com/statuses/update.xml
# curl -T myweather.sh ftp://ftp.saraswaticlasses.net/ --user shaileshr21:SomePassword
# upload a file to the server
# View returned HTTP header on a request
# curl -I http://www.google.com/
#BBC Mumbai weather id
id=1558
#BBC weather RSS feed address
feed="http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/${id}.xml"
#City
city=lisbon
#temporary file
tmpfile="weather${city}.txt"
#Weather twitter bot
twitbot=shantanuo:SomePassward
#Read the RSS feed and filter it
curl $feed 2>&1 | grep 'title' | tail -n 1 | perl -wlne'm/title>(.*)<\/title/i && print $1' | sed -e "s/°//g" > $tmpfile
#Read the forecast into a weather variable
read weather < $tmpfile
#Twit the weather variable away
curl --basic --user $twitbot --data status="$weather" http://twitter.com/statuses/update.xml




