You cant do this with Net::Telnet::Cisco the way it sounds like you are wanting it to act...You may have to go into somthing like this using just Socket...Somthing like this:
#!/usr/bin/perl
use Socket;
# no its a quicky, i didnt use strict..its hard to write
# code in this text box
$HOSTNAME = "hostname.of.router";
$TELNETTO = "where.to.telnet.to.from.hostname";
$USER = "username";
$PASS = "password";
while (1) {
socket(SOCK,PF_INET,SOCK_STREAM,getprotobyname('tcp'));
connect(SOCK, sockaddr_in(23,inet_aton("$HOSTNAME")));
select(SOCK);
$|=1;
select('stdout');
print SOCK "$USER\n";
while(<SOCK>) {
($stuff) = split(/\s+$/,$_);
if ($stuff =~ /Password:/) {
print SOCK "$PASS\n";
}
if ($stuff =~ /\>$/) {
# we have user access
print SOCK "telnet $TELNETTO";
# do some matching on its prompt
}
}
exit;
}
hope this helps a bit...its kinda what I had to do to get extended ping sweeps to work before.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.