Announcement

Collapse
No announcement yet.

Problem with PERL Net:Telnet:Cisco Script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with PERL Net:Telnet:Cisco Script

    The script runs and logs in and runs the first command but never outputs to the screen and does not continue on to the next command. Any thoughts?????

    #!/usr/bin/perl
    #
    # I hope this works.
    # The waitfor() function does not appear to be detecting the cisco prompts.
    # But the timeout of 20 seconds does seem to work ok with errmode=return.
    #
    use Net::Telnet::Cisco;
    my $addr = "10.75.1.16";
    my $device = "10.75.1.16";


    # Login
    my $session = new Net::Telnet::Cisco(Dump_log => 'dump.log', Timeout => 20, ErrMode => 'return');
    print "Connecting to $device at $addr...\n";
    $session->open($addr);
    $session->waitfor('/Username:/');
    $session->print("youknow");
    $session->waitfor('/Password:/');
    $session->print("iforgot");
    $session->waitfor("/>/");
    @env = $session->cmd('show env all');
    print @env;
    @ver = $session->cmd('show ver');
    print "Show Version \n @ver\n";
    $session->cmd('exit');
    $session->close;

  • #2
    Re: Problem with PERL Net:Telnet:Cisco Script

    I have this working now.

    I got it working...thanks for your help...



    use strict;
    use Net::Telnet::Cisco;

    my $host = '10.75.1.16';

    my $session = Net::Telnet::Cisco->new( Host => $host, -Prompt =>'/(?m:^[\w.&-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$)/');

    $session->login(Name => 'xxxx',Password => 'xxxxx');

    my @ver = $session->cmd('show ver');
    print @ver;

    $session->close();

    Comment


    • #3
      Re: Problem with PERL Net:Telnet:Cisco Script

      Thanks for updating!
      Marcel
      Technical Consultant
      Netherlands
      http://www.phetios.com
      http://blog.nessus.nl

      MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
      "No matter how secure, there is always the human factor."

      "Enjoy life today, tomorrow may never come."
      "If you're going through hell, keep going. ~Winston Churchill"

      Comment

      Working...
      X