Twittering from the Command Line

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:

Twitter Command Line Interface CLI for Linux

The result is equally tasty:

Twitter Command Line Interface CLI for Linux

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?

  • http://www.fsckin.com/ Wayne

    Ooooh new idea: pipe your latest tweet into fortunes, to get a reminder of what your latest status is.

  • http://www.bin-co.com/blog/ Binny V A

    I created a similar interface a while ago – Command Line Twitter Client.

  • cf

    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”

  • http://easierbuntu.blogspot.com Matthew

    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.

  • http://www.harck.be Harck

    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!

  • http://tech.shantanugoel.com Shantanu Goel

    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..

  • http://www.fsckin.com/ Wayne

    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.

  • http://kemitix.net Paul Campbell

    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

  • http://flashmonkey.servehttp.com/wordpress Ian Fuller

    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.

  • http://tech.shantanugoel.com Shantanu Goel

    @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 :)

  • Pingback: ¿Twitteando desde la línea de comandos de Linux? | Blog en Serio

  • strong silent type

    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.

  • http://www.dailygyan.com Anoop Engineer

    You don’t have to install curl.
    wget that’s installed by default will do

    http://www.dailygyan.com/2008/03/height-of-geekiness-post-to-twitter.html

  • http://roboRobert.com Jim Robert

    logfile garbage eh? sounds like a giant security hole haha

  • ikaruga

    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.

  • http://www.mjnbrn.net Ben

    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?

  • http://planetsuzy.org/showthread.php?t=80776 Nexcypeexceria

    thank you, guy

  • Pingback: n3wt0n! » Yet Another Command-Line Twitter

  • adhetlenadawl

    cialis ! cialis en ligne. viagra pharmacie Achat Cialis en ligne dans notre pharmacie. 8))) Achat de cialis en France avec livraison

  • Pingback: Tecnología y negocios » Twittering desde la línea de comandos

  • http://forum.joltiy.ru/member.php?u=34850 signs my ex wants me back

    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.