Custom Search

Sunday, November 01, 2009

Tweeting From the Command Line

Recently ran across an article Tweeting from the command line,
so I thought I’d give it a try. Didn’t have a Twitter account,
so that was the first step, creating one. Go to Twitter and
create your account.
After that, you need to copy the script and put in your username
and password and make the script executable. I placed my script
in ~/bin and did a chmod 700 ~/bin/tweet.sh so the script
is only executable, readable, and writable by me. Here’s the script:

#!/bin/sh

tweet="${@}"

user="username"

pass="sekret"

if  [ $(echo  "${tweet}" | wc -c) -gt 140 ];  then

     echo "FATAL: The tweet is longer than 140 characters!"

     exit 1

fi

curl -k -u ${user}:${pass} -d status="${tweet}"
https://twitter.com/statuses/update.xml >/dev/null 2>&1
if [ "$?" == "0" ]; then

echo "Successful tweet!"

fi

The full instructions are at the link listed above at
the beginning of this blog entry. It mentions escaping
special characters such as "?" and "!" for one thing,
and that’s important. I read the other night where you
can’t edit a "Tweet", only delete it, going on to explain
that anyone following you would not be in sync with your
Tweets if you deleted an entry and then entered a new
version of it. I erroneously thought, also, that to Retweet
meant doing a Tweet over, but it's actually more like
passing on what someone else has already Tweeted.
Obviously I've still got a lot to learn about Twitter, but
the script above should get my fellow CLI geeks going. ;)

Cheers!

Addendum:
TTYtter for Perl: More Tweeting from the command line


TTYtter: an interactive console text-based command-line Twitter client and Perl platform

Just a follow up on Tweeting from the command line.
Cool setup. ANSI Graphics, too. Check it out.


Cheers!

Labels: , , , , , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home