EmmonsNet

Geek Stuff

Home Software Linux Twitter'ing from the linux command line
Twitter'ing from the linux command line PDF Print E-mail
Written by Frank Emmons   
Wednesday, 05 August 2009 22:53

TwitterAre you the impatient kind of geek who just can't spend the three extra seconds required to login to the Twitter web interface just to let all your followers that you just recompiled your kernel?

Got your console open and curl installed? Then tweet away with lightening fast speed by typing the following at the command line:

curl --basic --user "<twitter username here>:<twitter password here>" --data-ascii "status=I am so 133t that I tweet from the linux command line" http://twitter.com/statuses/update.json

Substitute <twitter username here> for your twitter login and <twitter password here> for your twitter password and then press enter.

When you look at your twitter page now - you can see just how 133t you are and now everybody else knows it.

But that can get tiresome to type all that every time you feel the urge to tweet. That's why you can slap together a really simple bash script and let it do the grunt work for you.

#!/bin/sh

curl --basic --user "
<twitter username here>:<twitter password here>" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json"

exit 0

I saved the bash script in /usr/bin as a file called 'tweet'.  Then I made it executable by doing:

chmod 755 /usr/bin/tweet

Again, substitute in your username and password. You might notice that the string to set your status is now "`echo $@|tr ' ' '+'`". That tells bash to grab whatever string that you pass to the command when calling your script and use it as your status update.

Now to be quick on the draw with your tweets, all you have to type at the command line now is : 'tweet <unsert whatever updated status you want>'.

Last Updated on Wednesday, 05 August 2009 23:15
 
Share/Save/Bookmark