Re: Re: Re: Telnet into Cisco switches
by blue_cowdawg (Monsignor) on Jul 11, 2003 at 15:53 UTC
|
I am being lazy for the moment and not looking at the man page for Net::Telnet or Net::Telnet::Cisco.
There is a way to get Net::Telnet to write an audit log of the conversation between your script and the device. If
you invoke that you might get some idea of what is going wrong.
Peter L. Berghold | Brewer of Belgian Ales |
Peter@Berghold.Net | www.berghold.net |
Unix Professional |
| [reply] [Watch: Dir/Any] |
|
Yes, look into the dump_log:
dump_log - log all I/O in dump format
$fh = $obj->dump_log;
$fh = $obj->dump_log($fh);
$fh = $obj->dump_log($filename);
"Nothing is sure but death and taxes" I say combine the two and its death to all taxes! | [reply] [Watch: Dir/Any] [d/l] |
Re: Re: Re: Telnet into Cisco switches
by primus (Scribe) on Jul 11, 2003 at 18:43 UTC
|
okay all, i must appologize... but i hope you find this alittle humerous:
turns out the system admin mistyped the password my script was using... silly error.
sorry again | [reply] [Watch: Dir/Any] |
Re: Re: Re: Telnet into Cisco switches
by naChoZ (Curate) on Jul 11, 2003 at 15:34 UTC
|
Are there any oddball chars you may need to escape?
~~
naChoZ
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
In that case, I'd probably do the obvious and have it print out the login and passwd first so that you know exactly what's being submitted.
~~
naChoZ
| [reply] [Watch: Dir/Any] |
Re: Re: Re: Telnet into Cisco switches
by primus (Scribe) on Jul 11, 2003 at 16:00 UTC
|
here is my code, in case i am missing something obvious:
my $session;
$session = Net::Telnet::Cisco->new(Host => $switch->{IP});
$session->login(Password => $switch->{PASS1});
$session->close();
| [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
|
$session->login(Password => $switch->{PASS1});
login needs both username and password.
~~
naChoZ
| [reply] [Watch: Dir/Any] [d/l] |
|
$session->login(undef,'password');
because there is no username for the login, just a password, but that did not work. and the router has a prompt
router>
router#
router$
so is that okay? | [reply] [Watch: Dir/Any] [d/l] [select] |
|
Sometime after I wrote my script, my boss in his infinite wisdom decided to hack the sh*t out of my code and render it unreconizable and unreadable. Otherwise I would have posted sniglets of it here.
Here is what I remember of what I did when I wrote my login routine:
- First off I did not use the login method supplied by Net::Telnet or Net::Telnet::Cisco.
- Instead I used the print -- waitfor combination and decided what to do next based on ($match,$prematch)
- Since there are multiple passwords in our environmet for the network elemenets on our network. To get around that issue I used my own form of try<->catch type of logic.
Peter L. Berghold | Brewer of Belgian Ales |
Peter@Berghold.Net | www.berghold.net |
Unix Professional |
| [reply] [Watch: Dir/Any] |
Re: Re: Re: Telnet into Cisco switches
by primus (Scribe) on Jul 11, 2003 at 16:46 UTC
|
well, i think that the login routine they provide should work, i mean in the documentation they state, "All arguments are optional as of v1.05. Some routers don't ask for a username, they start the login conversation with a password request."
so i mean i think it should work just supplying the password. | [reply] [Watch: Dir/Any] |
|
Ah, ok, Didn't catch that. I haven't used it since approx 1.04. Did you try having it print the password to the screen 1st?
~~
naChoZ
| [reply] [Watch: Dir/Any] |
Re: Re: Re: Telnet into Cisco switches
by primus (Scribe) on Jul 11, 2003 at 17:43 UTC
|
yea... it prints fine to the screen | [reply] [Watch: Dir/Any] |
|
Sorry to beat this horse to death, but I just want to make sure of this, did you surround it so that you could make sure there weren't any extra spaces or chars in it? I usually do something like:
print "-->$foo<--\n";
So if there's a trailing space, for instance, it will output:
-->bar <--
~~
naChoZ
| [reply] [Watch: Dir/Any] [d/l] |
Re: Re: Re: Telnet into Cisco switches
by primus (Scribe) on Jul 11, 2003 at 18:04 UTC
|
well, i suppose i could give it a shot, but the file it is being read from has not spaces, "ipaddress,password"
and i chomp that when i read it in to get rid of the newline, also, i tried the password manually, $session->login(Password => 'password');
so i dont know how there could be a space... | [reply] [Watch: Dir/Any] [d/l] |
Re: Re: Re: Telnet into Cisco switches
by primus (Scribe) on Jul 11, 2003 at 15:55 UTC
|
well i tried even to hardcode the password in, and still no go...
$session->login(Password => 'password');
| [reply] [Watch: Dir/Any] [d/l] |