Perl telnet looping problem

From: CJ (chrisj_at_illicom.net)
Date: 03/21/05

  • Next message: Bjorn Jensen: "problems with decoding: resulting image is corrupt"
    Date: Mon, 21 Mar 2005 21:06:14 GMT
    
    

    Can someone look at the code below and tell me whats going on?

    Here is the problem. I can successfully telnet one of our routers and
    successfully put in a command in the while statement, but when the loop goes
    around a second time, it gives me:
    "pattern match timed-out at c:\filename.pl line 21"

    It can't get past the waitfor statement for a prompt the 2nd go around in
    the loop.

    Ideas??

    ======================================================

    use Net::Telnet;
    use constant PASS=>'password';

    $i=6300;
    $telnet = new Net::Telnet (Timeout=>25);

    $ip='<IP ADDRESS HERE>';

    $telnet->open($ip);
    $telnet->waitfor('/assword: /');
    $telnet->print(PASS);

    while ($i < 6400) {

         print "LOOPED!!!\n"; 'for troubleshooting purposes
         $prompt = $telnet->waitfor('/> /');
         print "MADE IT PAST PROMPT\n"; 'for troubleshooting purposes

         $statement=('<command goes here>');

         $telnet->cmd($statement);
         print "PORT FILTER ADDED\n"; 'for troubleshooting
         $i++;

    }

    $telnet->close;


  • Next message: Bjorn Jensen: "problems with decoding: resulting image is corrupt"