Bash Twitter Script

A small expansion to the twitter script: Howto Twitter From the Command Line in Ubuntu!

You still just “twitter Im a dooche” to post your every though.. But you dont have to worry about posting a +140 character message..

bin/twitter
# Post to Twitter

User=””
Pass=””
Twitter_Length=140

# Check msg length
text=$@

if [ ${#text} -gt $Twitter_Length ]
then
echo Error – Twitter only allows $Twitter_Length charachters; you have ${#text}
exit 1
fi

#Post it like its hot
curl -s –basic –user “$User:$Pass” –data-ascii “status=`echo $text|tr ‘ ‘ ‘+’`” “http://twitter.com/statuses/update.json” -o /dev/null
echo “Twittered ${#text} characters to $User”

Adds a check to the twitter script to see if the message length isnt too long, hides the curl output even more & gives an expanded final message.. You still need to slash your special characters like !,&,>,.. but there s no getting around that.

Published by Gert

Person-at-large.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: