#!/bin/bash # Used to post to twitter via command line. # Version 1.0 # # Installation: # chmod +x tw.bash # ln tw.bash ~/bin/tw # for local install # cp tw.bash /bin/tw # for system install CURL=/usr/bin/curl USERNAME="username" PASSWORD="password" # check if curl is installed if [[ ! -x $CURL ]]; then echo echo 'ERROR: curl is missing' exit 1 elif [[ $(echo "$@" | tr -d ' ') == "" ]]; then echo echo 'ERROR: No input... wtf?' echo "usage: tw \"message goes here...\"" exit 2 elif [[ $(echo "$@" | wc -m) > 140 ]]; then echo echo "ERROR: Your input was greater than 140 characters" exit 3 else $CURL -s --basic --user "$USERNAME:$PASSWORD" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json" exit 0 fi