-
-
Save delano/143213 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ tweet "your message" | |
# | |
# See: http://solutious.com/blog/2009/07/13/bash-twitter/ | |
# | |
# Contributors | |
# * @defunkt for the initial version | |
# * @anildigital and @grundprinzip for curl-fu | |
# * @solutious for the SSL sexytime | |
# See: http://curl.netmirror.org/docs/caextract.html | |
CERTS_URI=http://curl.haxx.se/ca/cacert.pem | |
# SHA1 digest for file: Thu Mar 26 21:23:06 2009 UTC | |
# NOTE: This needs to be updated when cacert.pem is updated | |
CERTS_DIGEST=331b7e928bd758146ef4a17fee59a63e6ad6b10a | |
# Path to local copy of CA extract | |
CERTS_FILE=~/.cacerts.pem | |
function tweet { | |
verifycerts || return 1 | |
if [ ! "$*" ]; then | |
echo 'Nothing to tweet!' | |
return 1 | |
fi | |
curl --cacert $CERTS_FILE -n -d status="$*" https://twitter.com/statuses/update.xml > /dev/null 2>&1 | |
echo "tweet'd '$*'" | |
} | |
# Download extract of CA certs from mozilla.org | |
function updatecerts { | |
curl $CERTS_URI > $CERTS_FILE 2> /dev/null | |
verifycerts | |
echo "Saved to $CERTS_FILE" | |
} | |
# Make sure the CA certs match the sha1 digest | |
function verifycerts { | |
if [ ! -f $CERTS_FILE ]; then | |
echo "$CERTS_FILE does not exist." | |
echo "Try running: updatecerts" | |
return 1 | |
fi | |
openssl sha1 $CERTS_FILE | grep $CERTS_DIGEST > /dev/null | |
if [ $? != 0 ]; then | |
echo "Digest mismatch for $CERTS_FILE (maybe it was updated?)" | |
return 1 | |
fi | |
return 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in ~/.netrc | |
machine twitter.com | |
login USERNAME | |
password PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment