[Net-Telnet] Line feed problems with login

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Net-Telnet] Line feed problems with login

Adam Stuckey
Hi All,

I am having a strange problem when trying to log into a remote system via
telnet.
My code works when logging into a Sun Solaris or HP-UX machine, but fails
when connecting to a particular device (a type of modem).
When I send the username, I append a "\r" to the end.  The remote device
immediately responds with "Invalid Password", before even asking my program
to enter the password.  I have ran an ethereal packet trace of what is
happening, and it appears that when I send "username\r", "username\r\n" is
actually sent to the remote system.  The remote system interprets this as
two enter presses, and believes a blank password was entered. Similarly, if
I send "username\n", "username\r\n" is actually sent to the remote node,
causing the same issue.
Is there a way to either prevent this additional "\n" being appended?  I am
using the out.write( byte ) method rather than out.writeln( byte[] ) so I
don't know where the additional "\n" is coming from.

Regards,
Adam


Disclaimer
___________________________________________________________

The information contained in this e-mail and any attachments are
confidential. If you are not the intended recipient, then please notify us
immediately by reply e-mail. You may not disclose or use the information in
this e-mail or attached documents in any attachments, use the contents for
any purposes, or disclose the contents to any other person: to do so could
be a breach of confidence. The views or opinions expressed in this email are
the author's own and may not reflect the views or opinions of Marconi.
Marconi does not guarantee the integrity of any e-mails or attached files
and we suggest you scan all incoming e-mails for viruses.
___________________________________________________________



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Net-Telnet] Line feed problems with login

SOMOGYI Erzsebet
Hi!

Adam Stuckey wrote:
> Is there a way to either prevent this additional "\n" being appended?  I am
> using the out.write( byte ) method rather than out.writeln( byte[] ) so I
> don't know where the additional "\n" is coming from.

I also had some \r\n problems. TelnetClient always sends \r\n as end of
line and doesn't care if you tries to send only \r or \n.

Conversion is done in org.apache.commons.net.TelnetOutputStream in
write(int ch) _and_ in org.apache.commons.io.ToNetASCIIOutputStream in
write(int ch). Output stream of TelnetClient is a ToNetASCIIOutputStream
which is initialized with a TelnetOutputStream (see _connectAction_() of
TelnetClient).

You could try  set __convertCRtoCRLF in TelnetOutputStream to false or
modify write method, and modify write method of ToNetASCIIOutputStream.

Finally I solved my problem on server side instead of modifing the
source codes, so I'm not sure about this solution.

Regards,
  Rzso

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Net-Telnet] Line feed problems with login

Adam Stuckey
In reply to this post by Adam Stuckey
Thanks Rzso,

I thought I was going crazy with what was happening!
Your advice pointed me in the right direction and I have now got things
working.

Cheers,
Adam

-----Original Message-----
From: SOMOGYI Erzsebet [mailto:[hidden email]]
Sent: Monday, 1 August 2005 11:19 PM
To: Jakarta Commons Users List
Subject: Re: [Net-Telnet] Line feed problems with login

Hi!

Adam Stuckey wrote:
> Is there a way to either prevent this additional "\n" being appended?  
> I am using the out.write( byte ) method rather than out.writeln(
> byte[] ) so I don't know where the additional "\n" is coming from.

I also had some \r\n problems. TelnetClient always sends \r\n as end of line
and doesn't care if you tries to send only \r or \n.

Conversion is done in org.apache.commons.net.TelnetOutputStream in write(int
ch) _and_ in org.apache.commons.io.ToNetASCIIOutputStream in write(int ch).
Output stream of TelnetClient is a ToNetASCIIOutputStream which is
initialized with a TelnetOutputStream (see _connectAction_() of
TelnetClient).

You could try  set __convertCRtoCRLF in TelnetOutputStream to false or
modify write method, and modify write method of ToNetASCIIOutputStream.

Finally I solved my problem on server side instead of modifing the source
codes, so I'm not sure about this solution.

Regards,
  Rzso

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Disclaimer
___________________________________________________________

The information contained in this e-mail and any attachments are
confidential. If you are not the intended recipient, then please notify us
immediately by reply e-mail. You may not disclose or use the information in
this e-mail or attached documents in any attachments, use the contents for
any purposes, or disclose the contents to any other person: to do so could
be a breach of confidence. The views or opinions expressed in this email are
the author's own and may not reflect the views or opinions of Marconi.
Marconi does not guarantee the integrity of any e-mails or attached files
and we suggest you scan all incoming e-mails for viruses.
___________________________________________________________



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]