Confessions of a Guru....

08 June 2008

Tweeting in Linux

Quickly tweet from your Linux environment with this script - all you need is the ability to launch a shell script, e.g. from a terminal, shortcut on your desktop or Gnome panel

Requires: curl, zenity.

Change the TWITTER_USERNAME and TWITTER_PASSWORD accordingly. Remember to make the script executable and since it contains your twitter username and password you most probably want u+rwx, go-rwx (or 0700).

#!/bin/bash
TWITTER_USERNAME=twitterusernamehere
TWITTER_PASSWORD=twitterpasswordhere

tweet=$( zenity --title "Tweet:" --entry )
if [ ! -z "$tweet" ]; then
result=$( curl -s -u $TWITTER_USERNAME:$TWITTER_PASSWORD -d status="$tweet" http://twitter.com/statuses/update.xml | grep -i "could not authenticate" | wc -l )
if [[ $result -eq "1" ]];
then
zenity --error --text="Error logging onto Twitter - please check your username and password or Twitter availability."
else
zenity --info --text="Tweeted!"
fi
fi

Custom Search

2 Comments:

  • Inspired by http://morethanseven.net/posts/posting-to-twitter-using-php/

    By Blogger Guru, at 8/6/08 23:07  

  • Hello. There is a small and easy-to-use PHP library for sending messages to Twitter and receiving status updates - http://phpfashion.com/twitter-for-php

    By Anonymous Anonymous, at 4/7/08 11:22  

Post a Comment

<< Home