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

2 Comments

Other Links to this Post

RSS feed for comments on this post. TrackBack URI

Leave a comment

WordPress Themes