Tweet from linux command-line

July 28, 2009

Hello there :)

you should read this post if you’re a Twitter fan ;)

today I read a tutorial about “Tweeting from your Linux Desktop

sounds interesting huh?! :)

okay lets figure out how to do that:

Create a bash script file (Example: Twitter.sh) in your home directory

then write this data into it:

#########################################

#!/bin/bash
USERNAME=”your-mail-or-username”
PASSWORD=”your-password”

URL=http://twitter.com/statuses/update.xml

result=`curl -u $USERNAME:$PASSWORD -d status=”Hello, i’m Tweeting from my linux command line” $URL`

exit 0

#########################################

you can also use it as a simple command by adding an alias to the “.bash_profile” file in your home directory

lets try it:

modify your script to be like this:


#########################################

#!/bin/bash

USERNAME=”your-mail-or-username”
PASSWORD=”your-password”

URL=http://twitter.com/statuses/update.xml

result=`curl -u $USERNAME:$PASSWORD -d status=”$1″ $URL`

exit 0

#########################################

then go to your home directory:

#cd ~

then:

#gedit .bash_profile

and add this line to the file:

alias twitter=’/home/your-username/Twitter.sh’

now you can use this command:

#twitter “Hello all, i’m tweeting from my command line”

——————————————————————-

you can find more in the Original post

Have fun ;)

7 Responses to “Tweet from linux command-line”

  1. angel Says:

    i will try it isA
    thanks :D

  2. dodage Says:

    I would use $@ instead of $1, so you can use it without quotes; ./twitter blah bleh bluh

  3. Kasidit Says:

    Great script! Thanks for sharing – now I can let many things twit – like twit the latest git commit log to fellow team members following a “commits” notification twitter account – via a git post-update hook calling this modified script.

  4. 4bd31h4m1d Says:

    gr8 thnx for sharing :D

  5. todd Says:

    Basic authentication is not supported
    You must use Oauth for twitter now, so this method will no longer work as of mid-2010.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.