« reading for the year | Main | hitting a ton »

twitter command-line status script

A long time ago, when nearly everybody I ever (thought I) wanted to talk to used goofey to communicate, one particular friend would often ask "what doing?". twitter seems made just for people like him. So in a retro moment I wrote some Perl to answer the age-old question from the comfort of the command-line, via twitter. It's called wd.

Once I'd written the "get" support, it wasn't too hard to add "set" support.

To use it, you'll need the Perl JSON module, and LWP. [update: and also DateTime::Format::Strptime - it'll sort the output by date, now.]

Getting status:

for all your friends

% wd
yeled: dreaming about driving into Western Australia as a fugitive a lot lately.. (about 16 hours ago)
wally: Sitting (about 21 hours ago)

for one particular friend

% wd wally
wally: Sitting (about 21 hours ago)

Setting status:

% wd -sv blogging. overdue for sleep
status set to: blogging. overdue for sleep

(if you leave the -v option out it'll shut up unless there's an error, in true Unix style.)

[update: there seems to be missing data in the feeds - if somebody marked their status as "friends-only", then you don't get a status object for them in the JSON and XML "friends status" feed. i've asked about it...]

Anyway, here's the script. Have fun!

wd

size: 4 KB.
last modified: 2008-06-07.

* 23:18 * geek

Comments have been closed for this post. If you've got something to say, please contact me by other means. Thanks!

Comments (6)

just when i was getting bored with twitter - i am re-energized!

Hmm. It was rather buggy. The version number is 1.09. I get all sorts of strange errors, - and it doesn't look as nice as yours.

I got it working a bit - but now I doesn't work anymore. Strange hardcoding the local timezone to australia.

Can't call method "strftime" on an undefined value at /usr/share/perl5/DateTime/Format/Strptime.pm line 805.

Everything is installed correct. --- But I see the version is older as the people doesn't have «:» after their nicks.

odin@acona:~$ wd
forteller Klart jeg m� slenge ut en test-post til twitter. Vet ikke helt hvordan jeg skal forholde meg til dette enda, om jeg kommer til � bruke det, og i s... (2006-11-22 01:52:15)

And it's not in UTF8, but AFAIK Twitter doesn't send that.

cos Author Profile Page:

Yeah, things have changed a bit since it was originally posted:

- twitter no longer provides relative dates via the API, so changed it to print boring-looking datestamps.
- i removed the colon so it'd flow a bit more like a sentence (which is how a few of us seem to use it).

I've just removed the Australian guff from it - sorry about that. You're the second person to give me any feedback on it, so it hasn't had a heap of testing beyond the standard "it works for me" disclaimer (and I'm still using it pretty much every day).

When are you seeing the strftime error? when you're setting your status with -s or just running it to see what other people are doing? is it happening every time?

Thanks,
Cos.

It won't work for me... I get this:
Can't locate JSON.pm in @INC (@INC contains: /System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/Library/Perl/5.8.6 /Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /Library/Perl /Network/Libra
BEGIN failed--compilation aborted at /usr/local/bin/wd line 63.

I tried doign the obvious $ sudo cpan install JSON

But it failed after about an hour of building dependencies with some test error, and I didn't have the heard to try again. What do I need to install to use this script? It's always a must to tell people that when and where you distribute software d-:

P.S. my bad for being a retard, you did specify that you needed the JSON module (-:

cos:

hm. "after about an hour of building dependencies"? you didn't let it try and build a new version of Perl or something, did you?