Twitter from the Command Line

This simple but not perfect script will let you twit easily from the command line.

Open a new file with your favorite text editor, and add this:

1
2
3
#!/bin/bash
curl --basic --user USERNAME:PASSWORD \
--data status="$*" http://twitter.com/statuses/update.xml -o /dev/null;

Save the file as twit (or any other name you choose).

Of course, we don’t like our password inside an accessible plain text file. So this is what I did:

sudo mv twit /usr/local/bin/.

sudo chmod 551 /usr/local/bin/twit

sudo +s /usr/local/bin/twit

sudo chown root /usr/local/bin/twit

Now, only root can read the file, but a regular user can execute it. Maybe my solution is not the best possible, but it works.

Anyway, now, you can use this to twitter from the command line:

twit “This was posted from the command line”

That’s it. Enjoy ;)


This post was based on a post from LinuxJournal.com


If you enjoyed this post, make sure you subscribe to my RSS feed!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

No related posts.

Tags: ,

Saturday, November 22nd, 2008 Command Line

1 Comment to Twitter from the Command Line

  • Brett Dreher says:

    Fun tip, finally gave me an excuse to sign up for twitter and give it a shot, thanks :)

  • Leave a Reply

    my email
    my photo
    Hi,
    My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
    I'm a Verification Engineer in Mellanox Technologies Ltd.
    I love Linux, the Command Line and the OpenSource Community.
    I used to write Poems (Arabic) when I was able to find time for this.
    November 2008
    S M T W T F S
    « Oct   Dec »
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
    SEO Powered by Platinum SEO from Techblissonline

    Twitter links powered by Tweet This v1.7.4, a WordPress plugin for Twitter.