I've never used that particular module. But I have used Net::Telnet a bit, and I don't believe the command output works in quite that way. Here is an exert from a script I've got to change passwords for people. Hope it helps, about the only thing of note is $PASSWD is my scalar it contains the path to passwd depending on if its going to solaris, irix, bsd, or linux.
The line I would point you towards is my($pre,$match) = $shell->waitfor(Match => '/Incorrect password/', this gets the output from the command so I can play with it.
open(STDERR, ">&STDOUT"); # changes STDERR to STDOUT, lets the p +assword thing actually work.... I think if ($METHOD eq 'telnet') { telnet_login($username, $password, $host, \$shell); # calls ou +t to temerity_lib.pl for the generic telnet log in process. NOTE: $shell is passed by referance # perform the actions we need to accomplish $shell->print($PASSWD); # start changing the password $shell->waitfor('/password:/i') or report_error("password","No + password prompt found");; # make sure it worked $shell->print($password); # send your login password my($pre,$match) = $shell->waitfor(Match => '/Incorrect passwor +d/', Match => '/New password:/') +; # make sure it worked $match =~ /New/ or report_error("password","Not prompted for n +ew password");; $shell->print($new_password); # send new password ($pre,$match) = $telnet->waitfor(Match => '/Bad password/', Match => '/Re-enter new passw +ord:/'); # make sure it worked $match =~ /Re-enter/ or report_error("password","New password +rejected"); $shell->print($new_password); # send new password again $shell->waitfor('/changed/i') or report_error("password","New +password rejected"); # make sure it worked $shell->close; }
and in case you want it here is telnet login
sub telnet_login # opens a telnet session to "host" { use Net::Telnet; # initialize the telnet module my ($username, $password, $host, $shell) = @_; # takes function arguments and stores them into appropriate variab +les $$shell = new Net::Telnet ('Timeout'=>'7', 'Errmode'=> sub { report_error("telnet" +,"Username or Password failed"); }, 'Prompt'=> '/.*([\$#\%>~]|\@\w~\$|\\\[\ +\e\[0m\\\] \[0m)\s?/' ); # initalizes a telnet object sets a prompt to expect sets a timeou +t sets error-checking $$shell->open(Host=>$host); # opens the object $$shell->login($username,$password); # login to the telnet sessio +n }
I wish I could offer more assistance.

jcpunk

In reply to Re: Net::Telnet::Cisco usage by jcpunk
in thread Net::Telnet::Cisco usage by chimni

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.