Tweet on twitter using Bash

Categories: bash

Just developed a simple script which uses the twitter API to post tweet on your twitter account. Don’t forget to replace USERNAME with your twitter username and PASSWORD with your twitter password.

#!/bin/bash
#tweet using bash
#coder : Anil Dewani

read -p "Enter Tweet:" twit
characters=`echo $twit | wc -m`
if test $characters -gt 140
then
        echo "Your tweet count is greater than 140 Characters"
        echo "Tweet Not Succesfully Posted!"
        exit
else
        curl -u USERNAME:PASSWORD -d status="$twit" http://twitter.com/statuses/update.xml -o /dev/null
        echo "Tweet Succesfully Posted!"
fi
exit 0

This script makes use of curl, so if you don’t have curl installed on your linux box, you can use following command to install it.

yum install curl

or

sudo apt-get install curl
Tags: ,
No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>