Skip to content


How to post to Twitter from the Linux command line

Linux

Twitter has become a big part the online lives of a lot of people in the recent months. Although in itself Twitter is a pretty simple service, which makes it easy for just about everyone to use it, it ships with an API which has helped people port it to just about every platform. Twitter has been ported to web browsers, to cellphones, and apparently even washing machines haven’t been spared. The Linux command line has always been a favorite of geeks. Here’s a trick that’s great fun, and could be useful if required.

Let’s see how to post an update to your Twitter account right from the Linux command line. This will also work on the MacOS X command line. Enter the following command in your terminal interface, replacing username and password with your Twitter account credentials, and status="Tweeting from the Linux command line" with your own message.

# curl -u username:password -d status="Tweeting from the Linux command line" http://twitter.com/statuses/update.xml > /dev/null

So if your Twitter username is fuzzycat17 and you password is fur123ball the above command will look like this:

# curl -u fuzzycat17:fur123ball -d status="Tweeting from the Linux command line" http://twitter.com/statuses/update.xml > /dev/null

Running this command will result in a new Tweet being posted from your account containing the words Tweeting from the Linux command line

Now go check your Twitter home page to see if the Tweet was posted correctly.

As I said, this trick could be completely for geekish fun, or could be put to good use. You could integrate this command into shell script to notify you of something.

Happy Tweeting.

Posted in Linux.

Get Simple Help tutorials just like this one in your email inbox every day - for free! Just enter your email address below:

 

You can always opt out of this email subscription at any time.

3 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. wock says

    Its cool tips, thx. How to make a script that implements these steps?

  2. Jon Payne says

    Can I assume that a a direct message or @ reply would simply be added to the sent string? For example curl -u fuzzycat17:fur123ball -d status=”@somename Tweeting from the Linux command line” http://twitter.com/statuses/update.xml > /dev/null; or status=”d somename . . . ”

    True?

Continuing the Discussion

  1. Tweet from the command line « Linux & Stuff linked to this post on May 6, 2009

    [...] in CLI, twitter Nice little trick from Simple Help. I tried this and it works perfectly. Only problem is there’s nothing to tell you you gone [...]



Some HTML is OK

or, reply to this post via trackback.