Updating Twitter via the command line on Linux is rather easy. But before I'll show you how, let me tell you a short story.I joined Twitter almost a year ago and only managed to update my status a few times. A very small number of friends followed me and I followed some people as well. I don't really intend to have thousands of followers on Twitter that's why I didn't advertise or mention it here before that I'm tweeting. However, as I noticed that Tech Source from Bohol now has a good number of loyal readers/subscribers, I realize that I should inform everyone that I'm tweeting HERE.
I'm doing this because instead of posting short personal updates on this site, I'm going to do it on Twitter, and I intend to do it more often. Also, I think it will give me the opportunity to get to know some our regular readers (Twitter users) since I often follow those who follow me. So, to everyone who always want to know what I'm doing (or what I’m not doing), follow me.
Now, here’s how to update Twitter from the Linux command line:
1. Install curl with this command (Ubuntu/Debian):
sudo apt-get install curl
2. Create a new file named ‘twitter’ at '/usr/bin' with your favorite text editor:
sudo gedit /usr/bin/twitter
Then, paste this code:
curl --basic --user "yourusername:yourpasswd" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json" -o /dev/null; echo Message Sent!
*Make sure you replace "yourusername" and "yourpasswd" with your own Twitter username and password. Save and Exit.
3. Give the file executable privileges with this command:
sudo chmod +x /usr/bin/twitter
4. Start tweeting using the command line by typing ‘twitter’ [space] [your message]. See example below:
twitter HELLO TWITTER WORLD!
5. You have just posted a Twitter update via the Linux command line!
$ twitter Hello from the Linux Command Line
% Total % Received % Xferd
Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
110 776 105 736 0 40 1177 63 --:--:-- --:--:-- --:--:-- 2115
curl: (6) Couldn't resolve host 'echo'
curl: (6) Couldn't resolve host 'Message'
curl: (6) Couldn't resolve host 'Sent!'
It posted on Twitter though with no problems. Thanks.
Excellent find though.
cheers Nick
I created a post on command line twitter a while ago - its almost exactly the same as your version. By the way, I think your are missing a semi-colon...
-o /dev/null; echo Message Sent!
http://apiwiki.twitter.com/REST-API-Documentation#TheEasiestWaytoPlayAroundwiththeTwitterAPI