HOWTO: Tweet from the Command Line Like a Pro With Curl

| No TrackBacks
twitter-logo.pngI recently stumbled across this awesome post via Twitter that explains how to Tweet from the command line like a pro using curl.  I tried it, and sure enough, it works!  If you want to Tweet a message from the command line using curl, here's how:

#/> curl -u mytwitterusername:mypassword \
-d status="from the cmd line!" \
http://twitter.com/statuses/update.json

Even cooler, if you want to pipe output into a Tweet (like your system uptime from the "uptime" command), you can run the following:

#/> curl -u mytwitterusername:mypassword \
-d status="my uptime:`uptime`" \
http://twitter.com/statuses/update.json

Note that if you are behind a corporate firewall at work, you will need to tell curl to use an HTTP web-proxy to communicate with the outside world.  This can be done using the -x option like so:

#/> curl -u mytwitterusername:mypassword \
-d status="from the cmd line!" \
-x web-proxy.example.com:8088 \
http://twitter.com/statuses/update.json

Or, if you wanted to pipe the output of a command into a Tweet, you can do so using the -d @- arguments which asks curl to read the POST input from <STDIN>.  Here's an example of piping the output of "df -h /" into a Tweet (to Tweet the usage of my root disk):

#/> echo "status=`df -h /`" | \
curl -u mytwitterusername:mypassword \
-d @- \
-x web-proxy.example.com:8088 \
http://twitter.com/statuses/update.json

For the HP-UX Tweeps out there (@HP_UX) ...

If you happen to be using a system without curl, you can easily install it.  On HP-UX, curl can be installed using the HP-UX 11i Internet Express package available from hp.com (HP-UX 11i v2 or HP-UX 11i v3).  As root on your HP-UX box, use the swinstall command to install your freshly downloaded .depot ...

swinstall -s /path/to/depot/internet_A.12.00.013_HP-UX_B.11.23_IA_PA.depot

Enjoy!

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

Send Mark a Direct Message

If you'd like to send me a direct message, please do so below. However, I do not publicly post comments or messages submitted directly to me. So, if you're going to try to SPAM me, or my blog, you're pretty much wasting your time.

400 characters remaining

Error

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer, a casual entrepreneur, and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on May 27, 2009 9:15 AM.

HOWTO: Whole Disk Backup and Recovery with dd, gzip, and p7zip (Linux on a CD too) was the previous entry in this blog.

A Couple of Quick jQuery Tips: Alternating Gray Rows in a Table, Highlight Table Row Mouseover is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.