Bash Script to Post to Twitter
By sterlo in Bash on 06/03/2009 at 17:02 (Old Revision)
Views: 122
Tagged: twitter, bash, cli, command, line, interface
URL: http://www.sterlinghamilton.com/blog/article/bash_script_to_post_to_twitter/
Starter:
Here is a quick/easy way to post to twitter from the command line interface.
Put the script in /usr/local/bin/
Then it is as easy as:
user@river:~$ twitter Your Message Here
Main Course:
#!/bin/bash # Login information. USERNAME="esupport@exyst.com" PASSWORD="pass" URL=http://twitter.com/statuses/update.xml # Check message length. if [ ! -n "$1" ]; then echo "Message not long enough" exit fi # Check message length again. message="$@" maxlen=140; len=`echo ${#message}` if [ $len -gt $maxlen ]; then echo "Your message was longer than 140 characters..."; fi # Post to Twitter. result=`curl -u $USERNAME:$PASSWORD -d status="$message" $URL`







