#!/usr/bin/perl
use warnings;
use strict;
use Net::Telnet ();
my $username="login";
my $passwd="password";
my $filename = "path_to_logfile";
my $t = new Net::Telnet (Timeout => 10, Binmode => '\015\012', Prompt => '/\[\]/', Dump_Log => $filename);
$t->open(Host => "127.0.0.1",
Port => 5005);
$t->waitfor('/Username: $/i');
$t->print($username);
$t->waitfor(-match => '/Password: ?$/i',
-errmode => "return");
$t->print($passwd);
$t->waitfor('/\[\]/');
my @lines = $t->cmd("show sessions");
$t->print("close");
$t->print("exit");
print @lines;
Комментариев нет:
Отправить комментарий