[Bash Script]Updating twitter via cURL

While reading some articles on LAMP [dot] ro, I came across an article on how to update your twitter status using cURL. Needless to say I could not stop myself from having some fun with BASH, cURL and Twitter. After about 15-20 minutes of playing around I made the following script:

echo "Twitter Terminal :: Update twitter with your computer data."
while [ 1 ]
[ -f /proc/meminfo ] &MEMUSED="$(( ( ( ( $MemTotal - $MemFree ) - $Cached ) - $Buffers ) / 1024 ))"
MEMTOTAL="$(( $MemTotal / 1024))"
MEMPER="$(( ( $MEMUSED * 100 ) / $MEMTOTAL ))"
echo "Commands: send, send_dm, brake, update.Memory"
read var_command
if [ $var_command == "update.Memory" ]; then
curl -u twitter_username:twitter_password -d status="Total memory: $MEMTOTAL mb, Unused memory: $MEMFREE mb, " http://twitter.com/statuses/update.xml;
if [ $var_command == "send" ]; then
echo "Type jur tweet nao, mortal: "
read tweet
curl -u twitter_username:twitter_password -d status="$tweet" http://twitter.com/statuses/update.xml;
echo "Your tweet has been send"
if [ $var_command == "send_dm" ]; then
echo "Receiver username: "
read receiver
echo "Message: "
read tweet
curl -u twitter_username:twitter_password -d user="$receiver" -d text="$tweet" http://twitter.com/direct_messages/new.xml
echo "Sent"
if [ $var_command == "brake" ]; then

Just change ‘twitter_username’ to your username and ‘twitter_password’ to your twitter password, and you are ready to go. Type send, press enter and then type your message. You can also send Direct Messages by using send_dm and update your status with data regarding free, used, and total memory available.


4 thoughts on “[Bash Script]Updating twitter via cURL

Leave a Reply

Fill in your details below or click an icon to log in:

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