in reply to Telnet to Cisco command prompt...

Please use the code tag for code:
#!/usr/bin/perl use Net::Telnet::Cisco ; my $switch = $ARGV[0] ; print "$switch \n" ; my $session = Net::Telnet::Cisco->new(Host => 'ba1-1'); $session->login('charlie', 'letmein'); if ($session->enable("letmein") ){ @output = $session->cmd('show privilege'); print "My privileges: @output\n"; } else { warn "Can't enable: " . $session->errmsg; }
Given this, I do not understand your question. Why do you think that you are still not logged in? If this is the end of the script, then of course you will no longer be logged in. The telnet session is within the context of the perl script. Once the perl script ends, the telnet session goes away.

If there is more to the script that you have not provided that seems to indicate that the login has terminated, I/we need to see it.

Replies are listed 'Best First'.
Re: Telnet to Cisco command prompt...
by WearyTraveler (Novice) on Sep 25, 2008 at 02:41 UTC
    I would like to create a "goto" script. I want to have the script leace me at the Cisco's command prompt. The script I have listed above logs me out when it completes. Rather than going through the user, pwd, en, pwd routine each time, I want to be able to execute the script and have it leave me in the enable mode. Thanks for any help! Charlie
      Sorry, you can't do that this way. The best you could do using this approach is to essentially write your own pass-through code after your login. It would read your info from stdin, package it as commands, use the perl interface to execute it and display the results.