Linux slogan
Visite também: Segurança Linux · BR-Linux.org · Dicas-L · Doode · NoticiasLinux · SoftwareLivre.org · UnderLinux



» Screenshot
Linux: FVWM transparente
Por leucas
» Login
Login:
Senha:

Se você ainda não possui uma conta, clique aqui.

Esqueci minha senha



Scripts

Linux user

Publicado por Danillo Souza em (última atualização em 02/09/2010)   [ 2946 hits ]

Login: danltmz, 33175 pontos

   


Descrição

Script que te possibilita enviar tweets pelo terminal, oferecendo proteção na hora da digitação da senha (igual a senha do comando 'su' por exemplo).

[ Download: tweetin ]   [ Enviar nova versão ]

[ Esconder código-fonte ]

#!/usr/bin/perl -w

# Author: Danillo Souza
# Email: danillo012@gmail.com
# Version: 0.1
#
# Small quick script to post tweets while working in the terminal
# or for use on systems that do not use graphical user interface (eg servers).
#
# I hope you use and like ;D

use strict;
use Net::Twitter;
use Term::ReadKey;

# get the password
sub get_pass {
   my($msg, $tmp) = (shift, '');

   print $msg;
   ReadMode 'noecho';
   $tmp = ReadLine 0; chomp $tmp;
   ReadMode 'normal';
   print "\n";
   
   return $tmp;
}

sub tweetin {
   # catch the username, password and the text f tweet
   my($user, $passwd, $tweet) = @_;
   # verifications
   if ($user !~ /^.{1,15}$/) {die "Invalid username.\n";}
   if ($passwd !~ /^.{6,}$/){die "Invalid password.\n";}
   if ($tweet !~ /^.+$/)      {die "Invalid tweet.\n"}
   if ($tweet !~ /^.{1,140}$/){$tweet = substr($tweet, 0, 140);}
   # create the twitter object
   my $twitter = Net::Twitter->new(
         traits   => [qw/API::REST/],
         username => $user,
         password => $passwd
      );
   # try to tweet it
   eval {$twitter->update($tweet)}; die "Autentication failed.\n" if $@;
   # if sucesful..
   print "Tweeted at ".scalar(localtime).":\n";
}

# checking the number of parameters
die "Usage: tweetin.pl <user> <tweet>\n" if (scalar(@ARGV) < 2);
# catching command line arguments
my $user  = shift(@ARGV);
my $tweet = shift(@ARGV);
my $passwd = get_pass "Password autentication:";

tweetin($user, $passwd, $tweet);

Scripts recomendados
   Script Linux recomendado Avisar por e-mail se o IP da conexão ADSL mudar
   Script Linux recomendado Automatizando o envio de arquivo p/ o FTP !
   Script Linux recomendado Getter - Gerencia downloads
   Script Linux recomendado HAT Googler
   Script Linux recomendado Servidor BBS

Comentários
[1] Comentário enviado por annakamilla em 08/09/2010 - 15:57h:

Can't locate Net/Twitter.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /usr/bin/tweetin line 17.
BEGIN failed--compilation aborted at /usr/bin/tweetin line 17.


[2] Comentário enviado por danltmz em 08/09/2010 - 16:05h:

Você precisa ter o módulo Net::Twitter instalado para usar, senão gera erro por não conseguir encontrar o módulo.

Use:

% perl -MCPAN -e "install Net::Twitter"


;)


Contribuir com comentário


  
Para executar esta ação você precisa estar logado no site, caso contrário, tudo o que for digitado será perdido.
Responsável pelo site: Fábio Berbert de Paula - Conteúdo distribuído sob licença GNU FDL
Site hospedado por:

Viva o Linux

A maior comunidade Linux da América Latina! Artigos, dicas, tutoriais, fórum, scripts e muito mais. Ideal para quem busca auto-ajuda em Linux.