Since I’ve started using Twitter, I’ve been on the hunt for a command line version, so I don’t need to start up a browser or send an SMS on my phone. As I found out, it’s pretty darn easy to Twitter from the command line.
In Ubuntu, install curl with
apt-get install curl, then create a file paste the line below into it, modify the username and password strings:
curl --basic --user "username:password" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json"
Save or copy the file into /usr/bin, and you’re done.
And then you can do something fun like this:
The result is equally tasty:
I’m brainstorming a few strange uses for this, something like setting up tweet notifications of long-running batch jobs that finally finish. Or this might be a good way to prank someone, just have a cron job running that spits out random logfile garbage every few days… LOL. You guys got any other ideas?
21 replies on “Twittering from the Command Line”
Ooooh new idea: pipe your latest tweet into fortunes, to get a reminder of what your latest status is.
I created a similar interface a while ago – Command Line Twitter Client.
The cron job could access /usr/games/fortune and then you could build fortune databases for different twitterbox pranks^h^h^h^h^h^happlications.
Of course with cron, the regularity would eventually be noted. You could put a random delay in the cron script that calls curl.
call it “critter”
How about posting everything you play on Last.fm to Twitter? I’m sure it wouldn’t be hard to get it up to say “I just played _ by _” every time you play something new.
Dave Taylor is speaking about this feature in Linux Journal this month. He will extend this in his next columns so stay tuned to get more ideas!
Though I dislike anything that makes me store my username/password in cleartext anywhere, it still indeed is a great idea.
Can also be used as a calendar application, tweeting at the right times, which in turn alerts u on phone..
ofcourse google calendar provides that anyways..
cf: “critter” – haha!
Matthew: Twitterfeed and your own personal Last.fm RSS feeds do the job just fine I would imagine – I’ve been using Twitterfeed and it works pretty fantastic.
Harck: I got LJ in the mail last night, didn’t have a chance to read it yet… I’ll have a look when I get a chance.
Cool idea, Wayne.
Shantanu: I’ve taken the command above and wrapped it in some checks that allow you to have your username and password in a secure file. http://kemitix.net/blog/2008-03-19/twittercommandline
Am I the only person who thinks twitter is a waste of time? Don’t get me wrong, I love all things geeky… but I really couldn’t give a **** when my friends are feeding their cats or peering out of the window.
P.S. Thanks for the heads up on virtual box, the latest VMware was terrible and virtual box has been amazing – given your experience with virtual box have you ever moved a virtual machine onto physical hardware? I would like to setup a machine before copying the image onto a new piece of HW.
@Paul: Heading over to ur blog
@Ian: I’m a fan of “true” laziness (I read that term somewhere recently, dont remember where), i.e. to automate/reduce steps in anything you can. But yes, I hear what you say about twitter. I just don’t get it. But anyways, I don’t get a lot of things in this world, and 90% of them are supercool, 10% are superduds (again, am I right in this?). So, twitter might fall into anyone of these, and I might not even know. bah, am thinking too much, time for a nap to get rest for all this effort that I just did 🙂
[…] de fsckin w/linux encontrado en Linux […]
You have the start of something interesting here. Perhaps you might like to cast your script a bit more in the “unix” style by making it print something only if anything goes wrong. curl’s –silent parameter can help, as well as shell redirection.
You don’t have to install curl.
wget that’s installed by default will do
logfile garbage eh? sounds like a giant security hole haha
Wow! Awesome tip.
@Ian Fuller@ – you’re right when people use twitter that way it’s a whole waste of time. But we’re much smarter than that here (I hope). For example, I’ve set up twitter with Remember the Milk…it reminds me of stuff I need to do through my phone and I can add stuff to my tasklist via twitter through my phone…although I haven’t actually tried that.
Question!!!! I ran did all this, and twittered. But, After twittering, I get a whole bunch of text printed before my prompt. Just checking to see if its normal?
thank you, guy
[…] 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 Fsckin.com […]
cialis ! cialis en ligne. viagra pharmacie Achat Cialis en ligne dans notre pharmacie. 8))) Achat de cialis en France avec livraison
[…] el blog de fsckin, encontré la forma cómo hacer para twittear desde la línea de comandos. la […]
Great – I should certainly pronounce, impressed with your web site. I had no trouble navigating through all the tabs and related information ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your customer to communicate. Nice task.