erik907
erik907

Reputation: 13

Autopage More_prompt matching with Net::Telnet::Cisco in perl

i seem to be having trouble with Autopage and more_prompt in perl Net::Telnet::Cisco (Using the Cisco module specifically for the --More-- prompt).

The command im submitting is timing out, assuming because its waiting on a --More-- prompt for a user to hit the spacebar. Autopage using the more_prompt should submit a single space when it matches a prompt like --More--. Ive set the more_prompt specifically so that it matches (at least i think my regex matches), but the command seems to still be timing out.

Any suggestions?

My code below:

my $cmd = 'show interface';
sub telnet_mua {
    my $telnet = Net::Telnet::Cisco->new();
    $telnet->open("$_[0]");
    $telnet->waitfor('/Username:/');
    $telnet->print($un);
    $telnet->waitfor('/Passcode:/');
    $telnet->print($pw);
    $telnet->waitfor("/$_[1]>>/");
    my @output = $telnet->cmd(String => $cmd);
    print @output;
};

telnet_mua("111.222.333.444", "testlab9400-2");

The error (line 33 in the whole script is the "my @output = $telnet->cmd(String => $cmd);":

command timed-out at mua_inventory.pl line 33

Here is what it looks like when i manually telnet into it, including the --More-- prompt:

testlab9400-2>> show int

--- ADSL Interfaces ---

Interface State Connection


9.0 DN-DN No RX/TX
9.1 DN-DN No RX/TX
9.2 DN-DN No RX/TX
9.3 DN-DN No RX/TX
9.4 DN-DN No RX/TX
--MORE-- (space = next page, CR = one line, Q = quit)

Also, ive attempted to set the more_prompt used by Autopage to '/^(--MORE--).*$/' but the command still times out.

Upvotes: 0

Views: 470

Answers (1)

erik907
erik907

Reputation: 13

I got it to match finally with '/(\s*.*)(--MORE--).*\s*/'

Case closed.

Upvotes: 1

Related Questions