I don't think so. You get a timeout either because the connection to 192.168.203.23 is broken, or because the cmd() successfully opens a telnet connection which gets no further input. Try print() instead of cmd() and then search ( waitfor() ) the prompts and deliver the correct responses. A combination of print("telnet ...") and login() might also work, saving you some work. Take care if you are connecting to some non-UNIX hosts (see Net::Telnet : Connecting to a Remote MS-Windows Machine).

I would attack this problem by manually logging into the first host using a telnet client (telnet or PuTTY) and then login to the second host. While doing so, I would write down every significant prompt (username, password, etc.) and the correct response to it. That way, I would gain certainty that my approach would work in principle. Then, I have everything at hand for scripting this task.

Next step is to detect error-conditions (ill. or expired password, connectivity problems, timeouts, etc.), so your script becomes more robust.

Update (in response to 919601, 919606):
Try @output=$t->cmd('show system'); instead of @output=$t->print('show system');
If you get a timeout, use cmd() with a proper Prompt => '....' argument.
Maybe you want @output = $t->cmd(String => "show system", Prompt => '/]> /'); ?


In reply to Re^6: telnet from a cisco telnet by Perlbotics
in thread telnet from a cisco telnet by Kumar Mantri

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.