6 use Data::Dump qw(dump);
14 return $telnet->{$ip} if exists $telnet->{$ip};
16 my $t = Net::Telnet->new( Timeout => 10, Prompt => '/#/' );
18 $t->dump_log('/tmp/log') if $ENV{DEBUG};
24 $t->waitfor('/Login:/');
26 $t->waitfor('/Password:/');
30 $t->waitfor('/Please input password:/');
36 return $telnet->{$ip} = $t;
40 my ($class,$ip,$port) = @_;
42 warn "# hash $ip $port";
49 $command .= ' ' . $port;
56 my($prematch, $match) = $t->waitfor('/(Press any key to continue \(Q to quit\)|#)/');
58 last if $match eq '#';
62 warn "## out = [$out]" if $ENV{DEBUG};
65 foreach my $line ( split(/[\n\r]+/, $out) ) {
66 warn "# $line\n" if $ENV{DEBUG};
67 if ( $line =~ m/^(\S+.*?)\s+:\s+(\S+.*)$/ ) {
71 warn "## $n = $v\n" if $ENV{DEBUG};
76 warn "## $ip $command ",dump $hash;
84 foreach my $name (@_) {
85 # warn "# copy $name ", dump( $row ),$/;
86 $row->{$name} = $hash->{$name};
90 $hash = command 'show interface';
97 $hash = command 'show adsl status';
102 $hash = command 'show adsl physical';
118 warn "# row = ",dump $row;
127 my $t = $telnet->{$ip} || die "no $ip telnet in ",dump($telnet);
137 warn "# telnet = ",dump($telnet);
138 logout($_) foreach keys %$telnet;