Glad you could stop by the Linux Basement site. Linux Basement is an informational Podcast about Linux, open source software and lots of other wonderful technology. If you want to find out more about open source technologies, subscribe and have a listen!

#linuxbasement is up at irc.freenode.net

MP3 Feed
Ogg Vorbis Feed
MP3 Feed (all episodes)
Ogg Feed (all episodes)

 

A Twitter Command for Your Terminal

Article 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

Rockin dude thanks! This is

Rockin dude thanks! This is the perfect way to do it. I would actually like to make my own /home/chad/bin directory, and then have the twitter script run from there. When I get that straight I'll post it up.
Chad

side note

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"
 
Finux
www.thelinuxsociety.org.uk

This was sent tp me

Hi Guys,
 
This was sent through a forum to me, it's a site with a lot of very good linux twitter stuff.  Hope someone finds a use for it
 
http://www.fsckin.com/
 
Finux
http://www.thelinuxsociety.org.uk

good find chad my man, good find in deed

Chad was saying that Ubuntu/Mint supports /home$USER/bin for your commands, which to me seems the natural place to store personal excutable scripts than /usr/bin
 
I suppose the question is if your the only person that uses your system or not, because if there in your home folder then no one else will get the benefit of them.  I'm the only person on my system and i have a seperate /home/ partition so i'll be moving all my personal scripts to /home/arron/bin
 
Nice find Chad, never knew it, thought i'd share it.  Might be of some use to some one
 
Finux
http://www.thelinuxsociety.org.uk

Persistant log-in

With this method, is curl logging in every time you post? I have limited experience with curl from a couple years ago. For those that twitter often, is there a persistant curl stream method so it doesn't log in every time?
BTW, I saw this script on the Ubuntu Unleashed site as you mentioned. Thanks for putting the script together and posting it here.
 
RE: ~/bin
I don't remember if you mentioned it on the podcast, but on Debian 4, you do have to add the .bashrc lines to add the /home/$USER/bin directory.

log in

Hi Jonasr,
Thanks for the feedbacki think for posting you do need to authenticate, however i'm not sure if you just pulling the page down to view it if you do, i imagine if your twit's are protected you would need to.  I think Kirok on here made a script that pulled down your latest twit's and who posted them as well, i'll need to ask him to post it to the bottom of this for you, or you could join us on IRC and have a chat there with him. irc.freenode.net #linuxbasement
I'll make a mental note about Debian but i'm not supprised you need to add it, you know what they say
Ubuntu: Old African word for can't configure Debian ;-)
 
Finux
http://www.thelinuxsociety.org.uk