[Cascavel-pm] Net::Telnet
vivan em dim.fm.usp.br
vivan em dim.fm.usp.br
Terça Maio 4 15:10:28 CDT 2004
Sim,
Mas eu preciso entrar como enable no router para dar sh conf...
Fiz algumas outras alteracoes, e agora jah consigo passar para enable.
Porem, o sh conf nao consigo ainda....
#!/usr/bin/perl
open (OUTPUT,">./saida.txt") or die ("can´t open file");
use Net::Telnet ();
########## IP LOGIN E SENHA ##############
$ip="10.22.15";
$login="burps";
$password="bleargh";
$enable = "argh";
#######################################
$t = new Net::Telnet (Timeout => 10,
Prompt => '/rtb0101\>/',
Dump_Log => './log.txt');
$t->open($ip);
$t->waitfor(/Username: /);
$t->print ($login);
$t->waitfor(/Password: /);
$t->print ($password);
$t->waitfor('/rtb0101\>/');
######## COMANDOS ###########
$t->print('ena');
$t->waitfor('/Password: /');
$t->print($enable);
$t->waitfor('/rtb0101\#/');
print OUTPUT ($t->print('sh conf'));
$t->close;
close OUTPUT;
[]´s
> Tente isso:
>
> #!/usr/bin/perl
> use Net::Telnet ();
>
> $LOGIN ="burps";
> $PASS ="bleargh";
> $IP ="10.22.4.15";
> $command = "sh conf";
>
> $tn = new Net::TelNet (Timeout => 180, Errmode => "return", Debug => 1);
> if ($tn) {
> $tn->open(Host => $IP);
> $tn->login(Timeout => 360, Name = > $LOGIN, Password => $PASS,
> Prompt => '/\>$/');
> $tn->cmd(String => $command, Prompt => '/\>$/");
> $nextLine = "1"
> while ($nextLine) {
> if ($nextLine = $tn->getline(Timeout => 15)) {
> $nextLine =~ s/\r//;
> print $nextLine;
> }
> }
> }
>
> Eu não cheguei a testar ... mas deve funcionar com algumas adaptações é
> claro.
>
> [ ]´ção
>
> Mago
>
>> >>>Oi,
>> >>>
>> >>>Alguem pode me dar um help no modulo Net::Telnet? Estou tentando
>> >>>utiliza-lo para acessar um router, mas sem sucesso... Onde estou
> errando?
>> >>>
>> >>>#!/usr/bin/perl
>> >>>use Net::Telnet ();
>> >>>
>> >>>########## LOGIN E SENHA ##############
>> >>>$login="burps";
>> >>>$password="bleargh";
>> >>>#######################################
>> >>>
>> >>>$t = new Net::Telnet (Timeout => 10,
>> >>> Prompt => '/rtb0101\>/');
>> >>>$t->open("10.22.4.15");
>> >>>
>> >>>$t->login($login, $passwd);
>> >>>@lines = $t->cmd("sh conf");
>> >>>print @lines;
>> >>>
>> >>>
>> >>>Tks,
>> >>>Adriano.
>> >>>
>
> Marco Lima
> marco.lima em e-via.com.br
> +55 21 81230667
> _______________________________________________
> Cascavel-pm mailing list
> Cascavel-pm em mail.pm.org
> http://cascavel.pm.org/mailman/listinfo/cascavel-pm
>
> --------------------------
> Esta mensagem foi verificada
> pelo sistema de antivírus DIM e
> acredita-se estar livre de Virus.
> Virus data file v4357 created May 04 2004
>
--------------------------
Esta mensagem foi verificada
pelo sistema de antivírus DIM e
acredita-se estar livre de Virus.
Virus data file v4357 created May 04 2004
Mais detalhes sobre a lista de discussão Cascavel-pm