Thanks ssandv, looks like I am getting somewhere and my code is not giving any comp errors. I have tried the  ->waitfor (match) and it seems to be working in a way. Here is my new code:

foreach $host ( @hosts ) { my $conn = Net::Telnet::Cisco->new(HOST => $host, Dump_log => + 'dump2.log',Timeout=>20, ErrMode => 'return'); if ($conn -> waitfor ('/Password:.*/')){ $conn->login( Passcode => $passw); } else { $conn->login( Name => $username, Password => $password) or die "ERROOOOR"; } print $conn->cmd("show int status"); $conn->close; };

The problem I am having now I know is with my regex statement. I am getting no output from my script, but when I replace $conn -> waitfor ('/Password:.*/') with $conn -> waitfor ('/Username:.*/') it will give what I request from switches where I only need to give the password. This is what my dump file gives:

< 0x00000: ff fb 01 ff fb 03 ff fd 18 ff fd 1f 0d 0a 0d 0a ÿû.ÿû.ÿ +ý.ÿý..... < 0x00010: 55 73 65 72 20 41 63 63 65 73 73 20 56 65 72 69 User Ac +cess Veri < 0x00020: 66 69 63 61 74 69 6f 6e 0d 0a 0d 0a 50 61 73 73 ficatio +n....Pass < 0x00030: 77 6f 72 64 3a 20 word: > 0x00000: ff fd 01 ff fd 03 ff fc 18 ff fc 1f ÿý.ÿý.ÿ +ü.ÿü. < 0x00000: ff fe 18 ff fe 1f ÿþ.ÿþ. > 0x00000: 73 68 6f 77 20 69 6e 74 20 73 74 61 74 75 73 0d show in +t status. > 0x00010: 0a . < 0x00000: 0d 0a 50 61 73 73 77 6f 72 64 3a 20 ..Passw +ord:

Please have a look at my regex statement. Any quidance will be welcome. Thanks

Thanks

In reply to Re^2: Net telnet Cisco Login by sout11
in thread Net telnet Cisco Login by sout11

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.