KpyM Telnet/SSH Server - Forum
how do I enable line mode for Net::Telnet? |
Sander |
how do I enable line mode for Net::Telnet? |
Apr 01 2006 01:19 |
|
Hello,
I'm trying to connect to a KpyM telnet server using the Perl module Net::Telnet. This isn't working because there are lots of escape characters in the output:
login:[10;8f
password timeout[11;17f
is there a way to disable this or do I have to modify the code for that? I would hope that the telnet negotiation would take care of this but I guess there is an incompatibility. Net::Telnet reports that the following has been negotiated:
RCVD WILL ECHO
SENT DO ECHO
RCVD DO NAWS
SENT WONT NAWS
RCVD WILL SUPPRESS GO AHEAD
SENT DO SUPPRESS GO AHEAD
RCVD WILL ECHO
RCVD WILL SUPPRESS GO AHEAD
Thanks for putting such a great piece of software out there for us,
Sander
|
Kroum Grigorov |
|
Apr 02 2006 10:10 |
|
You can not disable ESC sequences in the output, but control characters are usually either at the begining or at the end of the line. I'm not familiar with Net::Telnet but if you are waiting for certain string in the output, I can suggest you to search for it as a substring. For ex: instead of waiting the output to be exactly "login:" you can search for the "login:" string in the output.
Something that you can also try is to first filter ESC sequences from the output, I guess there even might be some built in function to do that in Net::Telnet module.
Kroum
|
Sander |
|
Apr 05 2006 00:09 |
|
I think it'll be easier for me to disable the escape sequences in the server instead. The problem is that net::telnet never gets logged in because of the escape sequences. I'm not sure I can log in except by using the built in function to do so.
Thanks for replying.
|
Kroum Grigorov |
|
Apr 05 2006 08:23 |
|
As for the ESC sequences as far as I read the net::telnet documentation they should be handled by the module itself and I don't think they are a problem. Instead you can try to send username and password without waiting for "login" prompt.
use Net::Telnet ();
$t = new Net::Telnet;
$t->open("my.telnet.server");
## net::telnet should handle esc sequences by default but just in case set it manually too
$t->telnetmode(1);
## hit "return" few times just to make shure we are at the login prompt.
$t->print("");
$t->print("");
$t->print("");
$t->print("");
## hoping that we are at login prompt now send the username and password
$t->print("my_username");
$t->print("my_password");
## we should be logged at that point
|
sander |
great |
Apr 05 2006 18:48 |
|
Thanks for looking into that. I'll give it a go and report.
|
© 2007 - 2008 Kroum Grigorov