Sending a tweet from the command line

Fancy sending a tweet from the command line on the Raspberry PI?

I found a really good script at sbprojects.com which guides you through both the code for the script and the other configurations needed to send command line tweets.

I am always very reluctant to include other people’s code without referencing it so check out
http://www.sbprojects.com/projects/raspberrypi/tweet.php for the full code and details.

1. You will need a free account at supertweet.net, you will need to make a note of the password as this will be used in the script.

2. Copy this code into a new document using nano ca
lled tweet

#! /bin/bash

# tweet
#
# This script sends tweets
# Use:
# tweet "String to be tweeted"
# Special characters may not be used if your string is not delimited by quotes
#
# Author: San Bergmans
# www.sbprojects.com
#

# Configuration variables
TWIT_USER="twitter_user_name"
TWIT_SECRET="supertweet_password"

# Other variables
TWIT_URL="http://api.supertweet.net/1/statuses/update.xml"
TWEET=$(echo "$*"|cut -c -140)

curl -u $TWIT_USER:$TWIT_SECRET -d "status=$TWEET" $TWIT_URL -s > /dev/null

Use the command chmod u+x tweet to make it an executable binary and make sure it saved in /bin

Send a tweet using tweet “this is a tweet”



Comments