Command Line Twitter

Just when I thought it couldn’t get any easier to send out a Tweet, I lucked out and found Command-line Fu.

While browsing some very cool command line tricks, I happened upon a command to send out a Tweet using curl from the command line. I’ve seen this kind of example before – there may even be something similar in the Twitter API Wiki – but for some reason it resonated with me this morning. After playing around with it a bit, I’ve tweaked it to my liking:

curl -s -u user:password -d status="$1" http://twitter.com/statuses/update.xml > /dev/null

You can drop this into a file using your favorite editor. Save it and make sure the file is executable (chmod u+x fileName). You can execute this file at the command line like this:

$ ./fileName "This is the text of my Tweet."

I’ve opted to redirect the output returned by executing the curl command (Twitter will respond to the request with an XML document) to the bit bucket. I’ve also opted to turn off the normal progress indicator used by curl by invoking the -s flag. Feel free to tweak this to your heart’s desire.

I’ll definitely be sending out more Tweets from the command line, and I’ll definitely be going back over to Command-line Fu for some more command line tricks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s