1. #!/bin/bash
  2. #
  3. # Send to twitter a message.
  4. #
  5. # Copyright (C) 2009 – Samuele ~redShadow~ Santi – Under GPL v3
  6. # Please visit : http://www.hackzine.org
  7. #
  8. # Just run this script to be asked for a message to publish on your twitter.
  9. # Twitter login informations are asked at the first run of the script, and
  10. # then saved into ~/.twitter-login for future use.
  11. #
  12. if [ -e ~/.twitter-login ]; then
  13. TWITTLOGIN=$( cat ~/.twitter-login )
  14. else
  15. TWITTLOGIN=$( Xdialog –stdout –title “Twittit” –inputbox “Insert twitter login:” 0 0 “login:pass” )
  16. echo $TWITTLOGIN > ~/.twitter-login
  17. fi
  18. if [ $TWITTLOGIN == “” ]; then
  19. Xdialog –title “Twittit” –msgbox “Twitter login not found. Please configure ~/.twitter-login or just remove it to be prompted for login informations.” 0 0
  20. exit 1
  21. fi
  22. MESS=$( Xdialog –stdout –title “Twittit” –ok-label “Send on Twitter” –inputbox “Insert status update:” 0 0 “” )
  23. if [ $MESS != “” ]; then
  24. # URLENCODE Message
  25. MESSU=$( echo “$MESS” | perl -MURI::Escape -lne ‘print uri_escape($_)‘ )”
  26. curl -u $TWITTLOGIN -d “status=$MESSU http://twitter.com/statuses/update.xml”
  27. if [ “$?” == “0” ]; then
  28. Xdialog –title “Twittit” –msgbox “Twitter status update successful” 0 0
  29. else
  30. Xdialog –title “Twittit” –msgbox “Twitter status update failed (curl returned status $?)” 0 0
  31. fi
  32. else
  33. Xdialog –title “Twittit” –msgbox “Skipped (empty message)” 0 0
  34. fi
Advertisements