#!/bin/bash # # Send to twitter a message. # # Copyright (C) 2009 - Samuele ~redShadow~ Santi - Under GPL v3 # Please visit : http://www.hackzine.org # # Just run this script to be asked for a message to publish on your twitter. # Twitter login informations are asked at the first run of the script, and # then saved into ~/.twitter-login for future use. # # source GET parameter -> set source if [ -e ~/.twitter-login ]; then TWITTLOGIN="$( cat ~/.twitter-login )" else TWITTLOGIN="$( Xdialog --stdout --title "Twittit" --inputbox "Insert twitter login:" 0 0 "login:pass" )" echo "$TWITTLOGIN" > ~/.twitter-login fi if [ "$TWITTLOGIN" == "" ]; then Xdialog --title "Twittit" --msgbox "Twitter login not found. Please configure ~/.twitter-login or just remove it to be prompted for login informations." 0 0 exit 1 fi MESS="$( Xdialog --stdout --title "Twittit" --ok-label "Send on Twitter" --inputbox "Insert status update:" 0 0 "" )" if [ "$MESS" != "" ]; then # URLENCODE Message MESSU="$( echo "$MESS" | perl -MURI::Escape -lne 'print uri_escape($_)' )" curl -u "$TWITTLOGIN" -d "status=$MESSU" "http://twitter.com/statuses/update.xml" if [ "$?" == "0" ]; then Xdialog --title "Twittit" --msgbox "Twitter status update successful" 0 0 else Xdialog --title "Twittit" --msgbox "Twitter status update failed (curl returned status $?)" 0 0 fi else Xdialog --title "Twittit" --msgbox "Skipped (empty message)" 0 0 fi