| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- use Modern::Perl;
- use utf8;
- use telnet;
- async purge_bdcom => sub
- {
- my $ip = shift;
- my $login = shift;
- my $password = shift;
- my $tree = shift;
-
- ############################
-
- my $t = new telnet($ip);
- # $t->debug(1);
- await $t->connect;
- await $t->reply(qr/Username:/, $login);
- await $t->reply(qr/Password:/, $password);
- my @greeting = await $t->waitfor(qr/>/);
- my $version = "C";
- for (@greeting)
- {
- $version = $1 if /Welcome to BDCOM P3310(\w)/;
- }
- $t->print("enable");
- my @next = await $t->waitfor(qr/#|password:/);
- if (grep {$_ =~ /password:/} @next)
- {
- $t->print($password);
- await $t->waitfor(qr/#/);
- }
- $t->prompt(qr/#/);
-
- await $t->cmd("terminal length 0");
- await $t->cmd("terminal width 200");
-
- #######################
-
- my @lines = await $t->cmd("show epon active-onu interface ePON 0/$tree");
- $lines[0] =~ m|Interface EPON0/\d+ has bound (\d+) active ONUs|;
- my $count = $1 || "?";
- $t->close;
-
- return $count;
- };
- 1;
|