Problem with PERL Net:Telnet:Cisco Script

Home Forums Scripting General Scripting Problem with PERL Net:Telnet:Cisco Script

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    etucker
    Member
    #143628

    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 @vern”;
    $session->cmd(‘exit’);
    $session->close;

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.