Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

See and post Twitter messages from Terminal UNIX
I found a couple of ways to update Twitter and read recent updates from the OS X command line. For instance, you can get all your tweets using the command line by using this command. (For some reason, retweets only show up as an "@" symbol, but your actual tweets will display correctly.)
curl -s http://twitter.com/your_user | grep '<span class="entry-content">' | cut  -d">" -f2 | cut -d"<" -f1
You can update twitter by using this command:
curl -u your_user:your_password -d status='This is My update' https://twitter.com/statuses/update.xml
[robg adds: I haven't tested these.]
    •    
  • Currently 2.63 / 5
  You rated: 4 / 5 (19 votes cast)
 
[11,850 views]  

See and post Twitter messages from Terminal | 23 comments | Create New Account
Click here to return to the 'See and post Twitter messages from Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
See and post Twitter messages from Terminal
Authored by: 36degrees on Apr 12, '10 08:01:10AM

Or you could… err... use the API? =/



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: elpaule on Apr 12, '10 08:03:56AM

yes, it is quite nice that most of the UNIX/GNU tools come with the OS.
If you want to read more about the twitter+commandline thing, you can delve into:

http://www.ibm.com/developerworks/linux/library/l-friendfeed/
or that one:
http://ubuntuforums.org/archive/index.php/t-1242129.html



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: marksch on Apr 12, '10 08:32:00AM
All items in the Twitter API documentation contain a cUrl example. You can read more about this at http://apiwiki.twitter.com/Twitter-API-Documentation Mark
---
Economy-x-Talk
Have your own custom software created
http://economy-x-talk.com


[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: xtex404 on Apr 28, '10 04:01:48PM

They also have a big fat warning over them not to use them, since they're turning off HTTP authentication on June 30.



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: Kalak on Apr 12, '10 10:16:23AM
Both work. Quick shell script:

#!/bin/bash
curl -u username:password -d status="$1" https://twitter.com/statuses/update.xml > /dev/null 2>&1
twitter.sh "Twitter scripts - now on a command line near me via MacOSXHints.com"---
--
Kalak
I am, and always will be, an Idiot.
---
--
Kalak
I am, and always will be, an Idiot.
Edited on Apr 12, '10 10:19:45AM by Kalak


[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: mkb218 on Apr 12, '10 10:41:13AM
You could just use TTYtter, which is an actual Twitter client.
---
mkb


[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: Anonymous on Apr 13, '10 09:35:08AM

See, this is a hint about using Twitter from the command line -- not using a Twitter application that happens to be a command line package.



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: VxJasonxV on Apr 12, '10 10:42:18AM

I would suggest users prevent their password going into their command line history file.

Leave off the :password part of curl.

e.g. curl -u username -d [...]

cURL will prompt your for the password, and it won't be saved or even displayed anywhere. It'll be run in the current context, and never again.



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: MurphyM on Apr 12, '10 12:47:16PM

I wrote something up on this a while back as a way to schedule a Tweet.

http://murphymac.com/twitter-while-you-sleep/



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: junkiesxl on Apr 12, '10 01:19:36PM

Or you could try out `beech ~ tweet from your homerow`: http://github.com/pjaspers/beech



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: rab777hp on Apr 12, '10 02:04:13PM

I just tested both, they work well.



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: marathonman on Apr 12, '10 03:30:05PM

I've been using this for a while to keep track of automated tasks on remote computers.

Near real-time updates to mobile devices? Yes please!



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: John M on Apr 12, '10 04:23:49PM

To read recent updates, keeping the retweets, hashtags and other stuff contained in html tags using sed.

curl -s http://twitter.com/your_user | sed -e '/<span class="entry-content">/!d' | sed -n '/^$/!{s/<[^>]*>//g;p;}' | sed -e 's/^[ \t]*//'

I'm not best with sed and I'm sure there is a more concise way of writing this.

John Maisey



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: Anonymous on Apr 13, '10 09:47:06AM

curl -s http://twitter.com/user | sed -n '/^$/d;s/^ *//;/class=.entry-content./!d;s/<[^>]\+>//g;s/^/* /;p'

Same thing but different. And it's still less than 140 characters.

Gotta love the "Edited on" remarks. As if it bloody matters.

Edited on Apr 13, '10 09:51:07AM by



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: John M on Apr 15, '10 09:22:38AM

Thanks. sed regex stuff makes my head hurt. :)



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: cagg on Apr 12, '10 07:34:02PM

My only comment is: why the H would you want to?



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: Anonymous on Apr 13, '10 09:56:29AM

This could be invaluable to sysadmins, or anyone requiring an automated notification.

Perhaps you put one in your login items. Perhaps you go further and incorporate it into a boot script that dumps the IP and uploads a picture captured from the built-in camera as part of an anti-theft device. Perhaps you just want to report your company's stock price.

See, a little imagination goes a long way, doesn't it? Now get back to your comfy "gooey" before I say something condescending.



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: cagg on Apr 13, '10 02:26:47PM

Ok, ok, I see your point.
(I hate to think what the condescending version of your reply would be.)



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: noodlejim on Apr 12, '10 11:26:43PM

Just have a look.
^_^



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: Paolo.Bosetti on Apr 13, '10 12:29:40AM

I also wrote a tool with some useful added feature. It is written in ruby and is super easy to install: just type

$ sudo gem install twt

then follow the short introduction and usage guide on http://github.com/pbosetti/twt.
Note for example that the command "twt delta" gives you the lists of new followers and lost followers too, since your last command invocation.
Hope that you like it.



[ Reply to This | # ]
Help, please!
Authored by: leamanc on Apr 23, '10 08:12:29AM

I am interested in trying twt, but I got an error when trying to install on 10.6.3. I do have XCode installed (I assume that's a prerequisite, but I don't know much about ruby).

mbp17:~ lcrews$ sudo gem install twt
Password:
When you HTTParty, you must party hard!
Building native extensions.  This could take a while...
ERROR:  Error installing twt:
	ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/yajl-ruby-0.7.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/yajl-ruby-0.7.5/ext/gem_make.out

Any ideas? Thanks!



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: xtex404 on Apr 28, '10 04:00:16PM

This won't work after June 30, when Twitter turns off HTTP authentication... http://dev.twitter.com/pages/auth



[ Reply to This | # ]
See and post Twitter messages from Terminal
Authored by: Matty23 on Jun 22, '10 02:47:05PM
You might want to look into using Twurl, which is described as "OAuth-enabled curl for the Twitter API." This will make sure that you're more future proof as Twitter has been warning of the shutdown of basic authentication (which this tip uses) for a while now.

[ Reply to This | # ]