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

################################################## ##### 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.
}

--
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/