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
ThanksIn reply to Re^2: Net telnet Cisco Login
by sout11
in thread Net telnet Cisco Login
by sout11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |