I love Twitter. Its such a good service. I think of it as Instance Messenger for the world. If you want to follow me, you can find my profile here. This post is going to be a little post which you can use Tweet anything from Terminal. Its useful if you want to set up a program or script to send results to Twitter. Its really simple to do. I’ll show you a quick one line method and a quicker method if you want to use this option more frequently.
The code is very simple. Basically it will send a specially command to Twitter on the update URL. This update URL will contain your message. On the face of it this command isn’t very secure, but it is useful if you want to send system messages as part of scripts to Twitter.
In Terminal type the following replacing the specific data as you need.
curl -u username:password -d status="message" http://twitter.com/statuses/update.xml
Simple one line. Very simple. It does work, for example this twitter post was made using this command.
If you think you will use this command quite frequently you can add it into a file. Open a new text document and add the following, save it as twitter.sh (or anything ending in sh)
curl -u username:password -d status="$1" http://twitter.com/statuses/update.xml
Make sure you change the chmod to 777 using the following command.
chmod 777 /path/to/file/
When you located the file (or add a bash prompt) it makes it simplier to twitter the rules. For example you can type the following to command to link to the file.
or with .bashrc
A cool little Terminal trick which I might use more frequently.
If you want to find out a bit more about Twitter and want to read a good book I recommend these two on Amazon, Twitter For Dummies and Twitter Means Business. Both are good books and I recommend you check them out.