Yet Another Command-Line Twitter

Recently this article made it to the front page of digg. It’s yet another article on how to update your Twitter status from the command line. It covers the bases of how to do it, but I still prefer Wayne’s way over at

First, the script requires cURL to be installed. So install it if it’s not already on your system.

sudo apt-get update
sudo apt-get install curl

I made some minor revisions to the Fsckin way to do it after reading the cURL man page and finding that the –basic flag wasn’t required etc.

It boils down to this

curl --user "username:password" \
--data-ascii "status=`echo $@|tr ' ' '+'`" \

Just copy the text into a file, I’ve called mine “tweet”, and change the username and password to your own information. Note, the text is there for anyone to see who has access to your computer. This is significant as your Twitter password is saved inside that file.

Change the file permission to make it executable:

chmod 755 tweet

And make a tweet on your Twitter profile

./tweet This message is what everyone will see.

which would post the message for everyone to see. You’ll end up getting some output from cURL. So long as it doesn’t come back with a short message which includes

<error>Could not authenticate you.</error>

then we can assume all went well.

Advanced Stuff

You might find that you want to be able to call the “tweet” utility from outside the directory it lives in. You can include the directory in your system path by adding the path to the bottom of your .bashrc

export PATH

So the next time you log in you can just type, from any directory,

tweet whatever the message is

and your twitter profile will be updated.

Personally I like to keep my scripts in a hidden directory in my /home. Something like /home/myusername/.my_scripts (or shorthand: ~/.my_scripts)

Leave a Reply

Staypressed theme by Themocracy