
Dwight Spencer
By: a guest on May 7th, 2009 | syntax:
Bash | size: 1.12 KB | hits: 72 | expires: Never
#!/bin/sh
# tweet.sh version 1.9
# a twitter client in cli
# (C)2008 Dwight Spencer (Den Zuko) <dspencer@computekindustries.co.cc>
# All Rights Reserved.
######################################################################################
# TODO:
# * add in checking for wget vs curl and gracefully drop to lwp-get
# * add in getopt support for username and password, also for https or http
# Chage Log:
# * added pwsafe support
usage() {
echo "Usage: `basename $0` <status>" && exit 0
}
die() {
echo "Opps something went wrong" && exit 1
}
[ [ $# -lt 1 ] && usage
MSG=$1
AGENT=$(which curl)
PWSAFE=$(which pwsafe)
[ $? == 1 && die
if [ -f $HOME/.tweetrc ]; then
auth=`cat $HOME/.tweetrc`
else
echo -n "Twitter Username: " && read -p "Twitter Username: " user
if [ =f $HOME/.pwsafe.dat ]; then
pass=$(${PWSAFE} -quE twitter.$user)
else
echo -n "Twitter Password: "
stty -echo && read pass && stty echo
fi
auth=${user}:${pass}"
echo $auth > $HOME/.tweetrc
fi
xmlrpc="https://$auth@twitter.com/statuses/update.xml"
$AGENT -d status="${MSG}" $xmlrpc 2>&1 1>/dev/null