Skip to main content


Showing posts from May, 2009

Twittering from the linux command line using curl

Recently I signed up for twitter and have found the need to "twit" from the command line. I found a quick tutorial on how to use curl to send twitter updates here:

I've decided to extend it a little bit by adding some error checking. I called the script "twit". Here is the source code:



if [ ${#@} -gt 140 ]; then
echo "The update you are attempting to send is ${#@} characters long."
echo "Maximum update length is 140 characters. Twitter update was not sent!"
exit 1

$curl --basic --user "$user:$pass" --data-ascii \
"status=`echo $@ | tr ' ' '+'`" \
"" > /dev/null 2>&1

if [ $? -ne 0 ]; then
echo "Curl returned a non zero return code. Failed sending twitter update!"
exit 1

exit 0

Nothing groundbreaking I know but it works …