Tuesday, August 18, 2009

Sending Tweet's From the Command Line

Saw tweeted by commandlinefu.com that you can use Curl to send tweets! I've been doing this an aweful lot lately. When I'm working, and need to send a quick tweet, I just use my handy little sendtweet.sh script.

Here is my "sendtweet.sh" script:
------------------------------------------------------

#!/bin/bash
if [ ! $1 ]
then
echo "Send Tweet. Usage:"
echo "$0 message"
echo
echo "This $0 script sends twitter status updates"
echo
echo "Make sure you escape anything but alphanumerics"
echo
exit
fi

curl -u twitter_username:twitter_password -d status="$*" http://twitter.com/statuses/update.xml
------------------------------------------------------

The if look is just to prevent me from doing anything stupid. You have to escape anything but alphanumerics, so usage is like:

sendtweet.sh Cool\, I\'m sending tweets from bash\!\!\!

Thought you all would enjoy that ;)

No comments:

Post a Comment