Twitter (”Twitando”) via shell com o CURL

Aug 20
2009

Como usuário de Linux, sempre procuro ferramentes simples que eu possa utilizar via linha de comando, como não encontrei nada pronto pro twitter, eu utilizer o aplicativo curl e criei um script para twittar via shell, segue ele.

——- COPIE AQUI ——–

#!/bin/bash
# twish: envio de mensagens para o twitter a partir do shell
# Sergio Cioban Filho

echo
echo "twish: Twitter via shell"
echo

TWITTER_USER=""
TWITTER_PASS=""

typeset -i NUM_LET=0
echo -n " - Enviando mensagem"
[ ! -z "$1" ] && NUM_LET=`echo -e $1 | wc -m` && NUM_LET="$NUM_LET - 1"
if [ $NUM_LET -gt 140 ]; then
    echo "   ...ERRO"
    echo "   Numero de caracteres eh maior que 140. NUM_LET=$NUM_LET"
    echo
    exit 1
fi

if [ ! -z $TWITTER_USER ] && [ ! -z $TWITTER_PASS ] && [ ! -z "$1" ]; then
    /usr/bin/curl -u $TWITTER_USER:$TWITTER_PASS -d status="$1" http://twitter.com/statuses/update.xml >&- 2>&-
    if [ $? -ne 0 ]; then
        echo "   ...ERRO"
        echo "   Nao foi possivel enviar a mensagem para o twitter"
        echo
        exit 1
    else
        echo "   ...OK"
    fi
else
    echo " Erro..."
    echo " Utilizacao: $0 \"\""
    echo " Nao esqueca de configurar o usuario e a senha no script"
    echo
    exit 1
fi

echo
exit 0

####### FIM DO SCRIPT

——- COPIE ATÉ AQUI ——–

Copie o código acima e cole em um arquivo, execute um chmod +x no arquivo criado, altere as variáveis TWITTER_USER e TWITTER_PASS para os seus dados de login no twitter e “have fun”!!! Twitter via shell

Atte.,
Sérgio Cioban Filho

42 Responses to “Twitter (”Twitando”) via shell com o CURL”

  1. Juliet says:

    I was just surfing for fun and then I found your web site. Great article. That’s a fine contribution. Thanks a ton for sharing! I have checked over a few of your other articles and found some great information too. Juliet

  2. Asia Landfried says:

    Sick of obtaining low amounts of useless traffic to your site? Well i want to share with you a new underground tactic that produces me personally $900 daily on 100% AUTOPILOT. I really could be here all day and going into detail but why dont you simply check their website out? There is really a excellent video that explains everything. So if your seriously interested in producing simple cash this is the site for you. Auto Traffic Avalanche

Leave a Reply

Visit Our Friends!

A few highly recommended friends...

Pages List

General info about this blog...