6 use Data::Dump qw(dump);
9 my ( $self,$ip,$port ) = @_;
11 warn "# hash $ip $port";
13 my $t = Net::Telnet->new( Timeout => 20, Port => 1123, Prompt => '/#/' );
15 $t->dump_log('/tmp/log') if $ENV{DEBUG};
20 $t->waitfor('/Login:/');
22 $t->waitfor('/Password:/');
26 #$t->waitfor('/Please input password:/');
35 warn "# command $command\n";
41 my($prematch, $match) = $t->waitfor('/(Press any key to continue \(Q to quit\)|#)/');
43 last if $match eq '#';
48 warn "## out = [$out]";
53 foreach my $line ( split(/[\n\r]+/, $out) ) {
55 if ( $line =~ m/^(\S+.*?)\s+:+\s+(\S+.*?)\s*$/ ) {
58 if ( $v =~ s/\s+(\S+)\s*:\s+(\S+.+)// ) {
60 my ($n2,$v2) = ($1,$2);
62 $hash->{ $section . $n2 } = $2;
64 $hash->{ $section . $n } = $v;
66 } elsif ( $line =~ m/^-+$/ ) {
67 $section = $last_line . '.'
72 warn "## hash = ",dump $hash;
77 $path = "/tmp/dump.$path";
78 open( my $fh, '>', $path ) || die "$path: $!";
81 warn "DEBUG ",$path, " ", -s $path, " bytes\n";
90 my @what = @_ ? @_ : keys %$hash;
91 foreach my $name (@what) {
92 warn "# copy $name ", dump( $hash->{$name} ),$/;
93 $row->{$name} = $hash->{$name};
97 $hash = command "show adsl port $port";
100 $hash = command "show adsl port $port line-config";
103 # FIXME very slow to query
104 #$hash = command "show adsl port $port physical-table";
107 warn "# row = ",dump $row;