#!/bin/bash # @name twitter.sh # @author Mark Stoecker # @homepage http://www.poundbangwhack.com # @namespace http://www.poundbangwhack.com/scripts/shell/post-to-twitter # @version 0.1 # @descripition This script will post to your twitter account from a # Linux shell. You will need to enter your username in the # configuration section. You will be prompted for your # password each time you run the script. ################### BEGIN CONFIGURATION ##################### # /** # * Set your Twitter username # * @var string # */ u="" ##################### END CONFIGURATION ##################### ################ DO NOT EDIT BELOW THIS LINE ################ clear function isgdurl() { su=`curl -s http://is.gd/api.php?longurl=$url` } while true; do read -p "Do you have a URL to shrink (y/n)? " yn case $yn in [Yy]* ) read -p "Enter URL to shrink: " url ; isgdurl $url; break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done ul=0 tl=0 ul=${#su} ml=$((140-(${#u}+5)-${#su})) while true; do read -p "Please input your tweet: " s tl=${#s} if [ $tl -le $ml ]; then break else echo "Tweet is too long by" $(($tl-$ml)) "characters" fi done tt=$s" "$su curl -su $u -d status="$tt" http://twitter.com/statuses/update.xml