A Twitter Command for Your Terminal

Post Type: 
Tutorial
A Twitter Command for Your Terminal

Well Twitter seems to be getting popular now, and it's pretty we documented that it can be used via the command line terminal if CURL is installed.  The below is how to make a twitter command for your terminal.  You will obviously need to have a Twitter account registered, and you can do that by going to this web address https://twitter.com/signup

The first thing to do is to install curl if it isn't already installed

sudo aptitude install curl

The we need to make a file which we will make executable, and store it in /usr/bin
I have used gedit but you can use any text editor you choose

sudo gedit /usr/bin/twitter

and place the following code into the newly formed file

curl --basic --user "yourusername:yourpasswd" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json" -o /dev/null
echo Message Sent!

You will need to replace "yourusername:yourpasswd" with your twitter username and password, save the file, and exit the text editor.

Then you will need to make the file executable by placing the following code into the command line terminal

sudo chmod +x /usr/bin/twitter

To use the newly created command you can type

twitter WHATEVER YOU WANT TO POST TO TWITTER

if your using a gnome desktop, you can press ALT+F2 and in the Run Command Box that appears type

twitter WHATEVER YOU WANT TO POST TO TWITTER

Most of the above was taken from this web site http://www.ubuntu-unleashed.com/2008/03/howto-twitter-from-command-line-...

and all though it was used for Ubuntu it should work on nearly all distributions, remember if you change your Twitter password then you'll need to update you /usr/bin/twitter file

Finux

www.thelinuxsociety.org.uk

Comments

side note

I've noticed and it's been raised by one or two people.  The script sometimes play's up, if it does try using it by putting the text between quotes like 

twitter "TEXT BETWEEN QUOTES"

Arron M Finnon
President
Abertay Linux Society


this site was sent

Hi guys,

Was sent this site through a forum that has some very nice Twitter stuff foe Linux, hope some of you can find a use for it

http://www.fsckin.com/

Arron M Finnon
President
Abertay Linux Society


/home/$USER/bin

Hi Guys,

Chad over at the Linux Basement was saying that Ubuntu/Mint supports executable scripts from /home/$USER/bin, which seems the logical place to store personal commands.  I suppose the question is if your the only person the uses your machine, because if you store them in your home folder no other user will get the benefit of them.

I'm the only one on this system, and i have a separate /home/ partition, so i'll be moving everything over to there, so if i reinstall or anything i'll still have my commands.

I'm sure a lot of you guys knew that already but if someone finds a use for it i'll be glad

Arron M Finnon
President
Abertay Linux Society


Can be used with a bit of tweaking

If the script is readable and executable by others then all they need to do is add the directory to their path, the /home/$USER/bin thing has been around for a while I think and on more than Ubuntu.