[Cascavel-pm] Net::Telnet
Your Name
marco.lima em e-via.com.br
Terça Maio 4 14:04:08 CDT 2004
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
Mais detalhes sobre a lista de discussão Cascavel-pm