Perl telnet looping problem

Discussion in 'Perl' started by CJ, Mar 21, 2005.

  1. CJ

    CJ Guest

    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;
     
    CJ, Mar 21, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuttermutt

    Perl telnet proxy

    Shuttermutt, Sep 3, 2003, in forum: Perl
    Replies:
    0
    Views:
    2,665
    Shuttermutt
    Sep 3, 2003
  2. Vinay Gupta
    Replies:
    2
    Views:
    1,125
    Michael Schlenker
    Jul 27, 2004
  3. Jim Isaacson
    Replies:
    5
    Views:
    612
    Default User
    Nov 5, 2004
  4. Carcarius
    Replies:
    0
    Views:
    314
    Carcarius
    Dec 6, 2007
  5. Replies:
    5
    Views:
    289
Loading...

Share This Page