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