Send Twitters from the Command Line in Any OS
Posted by Kevin Purdy at 2:10 AM on March 8, 2008
The Digital Streets blog posts a tip on how to send Twitters from a command line using a little utility named cURL. The blog shows the command to install cURL in Ubuntu, but the app is available for Linux, Unix and OS X, and Windows as well. Once you're set up, the terminal terminology is:
curl -u yourusername:yourpassword -d status="Your Message Here" http://twitter.com/statuses/update.xmlYou could save yourself a bit of time by putting most of that text into your preferred text replacement app, or setting up a terminal shortcut. Either way, it could be a convenient way to get at some of Twitter's more useful features, like setting GCal events, Remember the Milk, or just setting plain ol' SMS reminders. Got an easy way to set this up in your own OS? Share your experience in the comments.
Tags: command line | how to | linux | mac os x | terminal | top | twitter | unix

Comments (AU Comments · US Comments)
There are currently no AU comments for this post.
brucifer
Posted 3:46 AM 8/3/08
This is a neat tip and all but given how easy it is to use Twitter via your favorite IM client, it seems almost needlessly complicated.
brucifer
joelena
Posted 4:18 AM 8/3/08
Last year, Adam described how to combine cURL and Twitter with Launchy to quickly interact with your online organization tools:
[lifehacker.com]
joelena
inhouseprod
Posted 4:48 AM 8/3/08
Very cool . any thoughts on how to send a direct message to someone? (ie: Sandy?)
-eric
inhouseprod
kalebdf
Posted 4:48 AM 8/3/08
@joelena: Right on. I read that article last year too. There seem to be many more rehashed stories now-a-days.
I don't use this because that would be storing my password unencrypted. Why not enter at the time of? Repetition is the mother of annoyance. I wish Twitter and other APIs (del.icio.us) would allow a user to send a MD5 hash of their password.
Mmmm, I am going to get some hash browns.
-specialk
kalebdf
aufmobi
Posted 5:47 AM 8/3/08
command line tweetz, brilliant.
aufmobi
JiveMasterT
Posted 5:47 AM 8/3/08
@inhouseprod: Start your message with "d Sandy" or whatever the name is on Twitter. For rememberthemilk it's "d rtm".
JiveMasterT
legato
Posted 6:19 AM 8/3/08
Add something like this to your .profile (or .bash_profile etc):
tweet(){ curl -u username:password -d status="$1" ht tp://twitter.com/statuses/update.xml; }
(All on one line and without the space in "ht tp")
To send updates with:
tweet "message"
legato
ashwinphatak
Posted 6:19 AM 8/3/08
You could also use twittershell, my Python command line utility ([code.google.com])
It supports commands like:
update - to update your status
friends - lists your friends
tell - send a direct message to a friend
direct - lists direct messages sent to you
timeline - show your/friends timeline
status - show your/friends status messages
followers - list your followers
replies - list your replies
ashwinphatak
divergentdave
Posted 6:47 AM 8/3/08
@kalebdf: However, if you were able to send a tweet just using the MD5 of your password, then the MD5 would become as valuable as your password is now, and then you'd have to worry about storing the MD5 of your password in the clear.
divergentdave
31d1
Posted 8:29 AM 8/3/08
curl respects the ~/.netrc file if you use the -n flag. Somewhat more secure than having your pass in the ps listing.
31d1
KennyM
Posted 8:29 AM 8/3/08
@dirgentdave
Not really...MD5 is a one way hashing algorithm..If your password has any difficulty at all the hash will remain uncrackable for quite some time.
KennyM
thegooch49
Posted 8:29 AM 8/3/08
I think this is brilliant! I wrote a quick shell wrapper for this to make it even quicker. It contains your userID, but I left the password out. I wouldn't want it stored in a script in plain text. From here, I added an alias in my .tschrc file called tweet. It points to this script. Once set, I can type in tweet from my terminal, and it will ask what I'm doing. Type in an update, enter password (which is masked in the terminal) and I'm set! Works great for me.
Beware, this website trunkated the URL I posted, so use the URL posted in the article.
--Begin Code--
#! /bin/sh
printf "What are you doing? "
read update
echo
curl -# -u YOURUSERNAME -d status="$update" [twitter.com] >> /dev/null
echo "success"
thegooch49
danlowlite
Posted 8:29 AM 8/3/08
I would consider using this as part of an AutoHotKey script to let someone know on my phone that things have gone A-OK via SMS.
But then again, probably sendemail would be just as good.
Or maybe it's just a geeky thing.
danlowlite
ihopius
Posted 8:29 AM 8/3/08
Doesn't this send your user/pass as plaintext? Shouldn't the url be '[twitter.com]'
I think curl is smart enough to encrypt connections if an encrypted protocol is specified, but I'll have to check the man page to be sure.
ihopius
Madd_Matt
Posted 12:24 PM 8/3/08
@KennyM: But if I have the MD5 of your password, then I can just send that. A proper encryption scheme is needed, not just MD5 encrypting the password. HTTPS would do this.
Madd_Matt
Prolific Programmer
Posted 11:27 AM 9/3/08
Check out twitterupdate.rb, to keep up with twitter. I'm working on a GUI wrapper for it and evaluating the various frameworks. I'll need to use Windows and Macintosh. If anyone has suggestions, leave a comment on the linked entry. Many thanks!
Prolific Programmer
iqag
Posted 10:05 AM 10/3/08
You can do the same thing with wget, which is available by default on most Linux systems (cURL is not). Except for those of us who are always in the terminal, the main value to this is the ease with which it can be run through the GNOME Deskbar or Katapault and other similar "launchers".
Having the password stored in a file rather than show up in the process list is only a concern on shared systems. And it will be permanently available in the file if your system is compromised, whereas its presence in ps is very fleeting. As for SSL, both cURL and wget are capable of it, and I doubt most of the Twitter front ends are using it. And, it's your *Twitter* password, not your bank account. (cf. [gilesbowkett.blogspot.com])
iqag
chimeric
Posted 5:45 AM 11/3/08
For the security aware: You can use [] instead of [], to make this nice tip a little more secure.
chimeric
JoshMcAdams
Posted 5:45 AM 11/3/08
App::Tweet has been around for a month or so now. It installs a 'tweet' command that lets you twitter from the command line and also stores your user name and password securely.
[cpan.uwinnipeg.ca]
Anyone can just install 'App::Tweet' from CPAN and they will magically have 'tweet' on their system. Then just run tweet and it will ask for your authentication info. After that, tweet away from the command line.
JoshMcAdams
kalebdf
Posted 1:49 PM 13/3/08
@divergentdave & @Madd_Matt: That would most definitely be the case making the MD5 just as valuable. They need to have temporary auth tokens or some other nice way of simply authorizing an account.
@iqag: I like your point. It is just your *Twitter* password.
-specialk
kalebdf