Thursday, February 19, 2009

Quick Twitter status

Just a quick little script modified from the one found here http://cutup.org/anize/?twitter_bash_curl

I hardcoded the username/password and stripped out the “friends” statuses. For my purposes (http://appliedresearchwi.com headline) I only need “my” current status.

The script is run from crontab as follows:


*/5 * * * * /home/zachpeters/appliedresearchwi.com/etc/twitter.sh > /home/zachpeters/appliedresearchwi.com/etc/twitter.status

Code - note the “username” and “password” need to be changed:



#!/bin/bash
# Originally from - http://cutup.org/anize/?twitter_bash_curl
function getlastpost {
curl -u username:password 3 --connect-timeout 5 -s -n $1 | awk '
{ sub(/^[^>]*>/,”",$0) }
/text/ {
sub(/<[^<]*>$/,”",$0)
m=$0
}
/relative/ {
sub(/<[^<]*>$/,”",$0)
at=$0
}
/_name/ {
sub(/<[^<]*>$/,”",$0)
#print $0 ” : ” m ” [" at "]”
print $0 ” :: ” m
}
'
}
getlastpost http://twitter.com/statuses/user_timeline.xml?count=1

No comments: