My perl script times out when I try to telnet to another router/switch from a router. I am able to successfully telnet to the first router. I'm able to set the terminal length and width to 0. I'm able to send the command "telnet 10.0.0.1" and see in my dump_log and input_log that the program gets to the next device prompt which is /username: $/. For the life of me, I cannot get Perl to send my username. I've used print commands to no avail. I've used waitfor to specify the username prompt. I've used the prompt command as well but nothing works. I can attach my code but here are the contents of my dump_log and input_log first:

output_log (truncated): < 0x00000: 54 72 79 69 6e 67 20 37 33 2e 31 39 2e 32 33 37 Trying +x.x.x.x < 0x00010: 2e 35 2e 2e 2e 0d 0d 0a .x..... +. < 0x00000: 20 55 73 65 20 63 6f 6e 66 69 67 75 72 65 64 20 Use co +nfigured < 0x00010: 73 6f 75 72 63 65 20 69 6e 74 65 72 66 61 63 65 source +interface < 0x00020: 28 4c 6f 6f 70 62 61 63 6b 30 29 2e 0d 0d 0a (Loopba +ck0).... < 0x00000: 20 55 73 65 20 36 38 2e 38 37 2e 32 35 33 2e 34 Use x. +x.x.x < 0x00010: 20 61 73 20 6c 6f 63 61 6c 20 61 64 64 72 65 73 as loc +al addres < 0x00020: 73 2e 0d 0d 0a s.... < 0x00000: 43 6f 6e 6e 65 63 74 65 64 20 74 6f 20 37 33 2e Connect +ed to x. < 0x00010: 31 39 2e 32 33 37 2e 35 2e 0d 0d 0a 45 73 63 61 x.x.x.. +..Esca < 0x00020: 70 65 20 63 68 61 72 61 63 74 65 72 20 69 73 20 pe char +acter is < 0x00030: xx xx xx xx xx xx xx xx '^^'... +. < 0x00000: 0d 0a 0d 0a 63 65 2d 6f 72 70 6b 66 6c 68 64 30 ....xx- +xxxxxxxxx < 0x00010: 30 77 2e 63 70 65 2e 66 6c 2e 6a 61 63 6b 73 76 xx.xxx. +xx.xxxxxx < 0x00020: 69 6c 20 4c 45 2d 33 31 31 76 20 30 30 3a 30 33 il xx-x +xxx xx:xx < 0x00030: 3a 31 38 3a 66 35 3a 39 39 3a 38 30 0d 0a 0d 0a :xx:xx: +xx:xx.... < 0x00040: 75 73 65 72 6e 61 6d 65 3a 20 usernam +e: xxxxxxxxxxx@xxxxxxxxxxx:~/xxxx/xxxxxxxxxxxxxxx/xxxxxxxxxx>
Input_log xxxxx:xxxxx#telnet x.x.x.x Trying x.x.x.x... Use configured source interface(xxxxx). Use x.x.x.x as local address. Connected to x.x.x.x. Escape character is '^^'. xxxxx xxxxx xxxxx username:

Here is the code I'm using for the telnet and the username/pw input. Again, the problem is that I cannot get Perl to output the username I am giving it.

$session_parent->cmd("telnet $cienaIP"); $session_parent->waitfor('/username: $/i'); $session_parent->print($username); # $session_parent->print('username'); I've tried this # $session_parent->cmd($username); I've tried this # $session_parent->login($username,$password); I've tried this # I've tried very long regex expressions thinking that maybe I need to + match # the whole expression "Trying x.x.x.x Use configured....username: " o +utput # but that hasn't helped either.

In reply to Telnet to 1 router through another router by cpprather

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.