
Can I send Twitter updates from the command line?I'm becoming a big Twitter fan, but as a Linux user, I find it darn frustrating that most of the apps out there are for Mac and Windows users. I mean, I'm used to it, but is there at least some way to get to Twitter from the command line? Actually, there are a number of interesting Linux apps for Twitter, now that you mention it. Check out both the Twitter Fan Wiki and the Twitter download page for some of your options. Since Twitter has a nice, albeit simple, API, there are also some methods that you can use to access Twitter from the command line, as you seek. Of course, monitoring the twitterstream, public or otherwise, is difficult because the output formats are all a bit tricky to parse, but certainly adding your own Twitter status updates is straightforward. The trick is to use the terrific utility curl. Let me show you the basic command line invocation: curl --basic --user "$user:$pass" --data-ascii \
"status=`echo $@ | tr ' ' '+'`" "http://twitter.com/statuses/update.json" Obviously, you'll need to set your Twitter username and password in the script (which means that the script won't be secure) which you can do like this: user="DaveTaylor"
pass="I'm not going to show you here!" Then the sequence of "$@" is simply the command arguments you've specified to the script. So if it's called "send-twitter" you could send an update on the command line as simply as: $ send-twitter Watching Shrek, completely unmotivated to go outside today
That should get you going with the scripting. In terms of how to script monitoring the Twitterstream itself, that's a topic I'll be tackling in my Linux Journal shell scripting column in a month or two. Keep an eye out for it at the newsstand! Finally, please be aware that I have a variety of twitter help here, and you can also monitor my twitterstream if you'd like too! Tip o' the hat to Binny, who originally presented this basic script idea on his blog.
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
Shell Script Programming
(Article 7797)
Tagged: shell scripting, twitter Previous: How do I create my own Google Profile? Next: How do I search the patent database? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. Dave--Thanks for the article and I'm happy that you continue to cover shell script stuff. Hey, thanks for the mention. Posted by: Binny V A at May 11, 2008 12:35 PMI have a lot to say, but ...
I do have a comment, now that you mention it!
|
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|