Home   >>   Scripts   >>   Bash Script To Update Twitter Status From Command Line
Bash Script To Update Twitter Status From Command Line PDF Print E-mail
( 0 Votes )
How To - Scripts
Written by Christian Foronda   
Saturday, 11 September 2010 20:13

Create the script:

# vi /usr/bin/tweet

 

#!/bin/sh

tweet="${@}"
user="YourUsername"
pass="YourPassword"

if [ $(echo "${tweet}" | wc -c) -gt 140 ]; then
echo "FATAL: The tweet is longer than 140 characters!"
exit 1
fi

curl -k -u ${user}:${pass} -d status="${tweet}" http://twitter.com/statuses/update.xml > /dev/null 2>&1

if [ "$?" == "0" ]; then
echo "Successful tweet!"
fi

echo "Usage: $0 "{tweet "My tweet update"}""

 

# chmod +x /usr/bin/tweet

 

Usage:

# tweet "Update from bash script"



blog comments powered by Disqus
Last Updated on Tuesday, 15 March 2011 08:22