View Single Post
  #4   Report Post  
Posted to rec.crafts.metalworking
Ignoramus3943 Ignoramus3943 is offline
external usenet poster
 
Posts: 5
Default Bash function to post to Twitter via command line

On 2009-03-26, DoN. Nichols wrote:
On 2009-03-25, Ignoramus23425 wrote:
################################################## ##### Twitter
# Usage:
#
# Twitter I am eating sushi right now
#
Twitter() {
local USERNAME=myusername
local PASSWORD=mypassword

# Verify that you have URI::Escape perl module.
if perl -MURI::Escape -e exit; then
true
else
echo "perl Module URI::Escape missing. You need to install it." 1&2
return 1
fi

MESSAGE=$(echo -n "$@" | perl -MURI::Escape -ne 'print uri_escape( $_ )')

COMMAND="curl --basic --user $USERNAME:$PASSWORD --data-ascii status=$MESSAGE http://twitter.com/statuses/update.json"
$COMMAND /dev/null 2&1 && echo Success.
}


Nice and simple -- but I would have added a test to make sure that the
username and password had been set to something other than the defaults
you have in there. Or perhaps able to read them from a file like
~/.twitter/accountname so you could use it for mutiple accounts by
typing "twitter junque I am eating sushi right now" and it would read
the username and password for account "junque" before proceeding.


This is what I do, I have a file ~/.../.../twitter.txt with username
and password. It is secret. My family shares my .bashrc, so I cannot
have my twitter password there (which is unique and is not used on any
other website), but I have it in a secret file.

Now -- all I need to do is to create a twitter account -- and
find people who are interested enough in my day-to-day minutiae to read
it. :-)


Well, when posting your minutiae is as easy as typing something on
command line, you may reconsider.

--
Due to extreme spam originating from Google Groups, and their inattention
to spammers, I and many others block all articles originating
from Google Groups. If you want your postings to be seen by
more readers you will need to find a different means of
posting on Usenet.
http://improve-usenet.org/