You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Daniel Wikman <da...@hotmail.com> on 2006/12/03 08:51:02 UTC

TelnetClient problem?

Hi all!

I wonder if someone has seen this and know a "cure" for this behaviour. I wrote a program based 
on the commons.net TelnetClient class. When using the program towards a Unix or Linux box 
directly everything works fine, but when using telnet towards a serial blackbox, I always get an 
extra newline added when writing commands (it seems like TelnetClient or the underlying stream 
makes line terminations a la windows... The fun part is that if I make my own TelnetClient program 
based on Java.util.ProcessBuilder it works just fine. I'd really like to make my program independent 
of the "/usr/bin/telnet" to make it work on windows platform as well. Does anyone know what 
option that controls this in TelnetClient? 

BR

/Daniel 

Re: TelnetClient problem?

Posted by Michael Erskine <ms...@yahoo.co.uk>.
On Monday 11 December 2006 06:18, Daniel Wikman wrote:
> '\r\n' is in
> fact a windowze construct, and I operate mostly on solaris/linux but also
> of course on
> windows. Shouldn't this be made configurable???

CR LF is also a telnet construct - see RFC854

Regards,
Michael Erskine.

-- 
If you're going to do something tonight that you'll be sorry for tomorrow
morning, sleep late.
                -- Henny Youngman

		
___________________________________________________________ 
Copy addresses and emails from any email account to Yahoo! Mail - quick, easy and free. http://uk.docs.yahoo.com/trueswitch2.html

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: SV: TelnetClient problem?

Posted by Michael Erskine <ms...@yahoo.co.uk>.
On Wednesday 13 December 2006 21:13, Daniel Wikman wrote:
> Well Michael, I do not see how that can solve my problem...

Sorry Daniel, I wasn't offering a solution: just some information :)

Unfortunately I'm not at all familiar with TelnetClient, or even the telnet 
protocol: I just remember reading somewhere that CR/LF combinations can be 
used. Perhaps there's some metadata that the TelnetClient is not passing to 
the telnet daemon at the other end. One thing to try is to use ethereal to 
see what is different between the proper working telnet session and 
TelnetClient.

Regards,
Michael Erskine.

-- 
By failing to prepare, you are preparing to fail.
Send instant messages to your online friends http://uk.messenger.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


SV: TelnetClient problem?

Posted by Daniel Wikman <da...@hotmail.com>.
Well Michael, I do not see how that can solve my problem... 

I have an application that needs to telnet in to a remote system
and run your regular passwd command to set the password, just like
in many operating systems. When using TelnetClient class towards the
Remote system directly it works fine, but the remote system also is
Connected through a serial port to a blackbox, so 
$ telnet <blackbox ip> <blackbox port> 
Gets me connected as well, but when using TelnetClient towards this
Blackbox, I get an extra newline at every command rendering an empty
Password. I.e.

$ passwd<i entered this newline...>
Enter password:<This newline is TelnetClient added :)>
Confirm password:<my entered password ends up here and a newline of course>
Passwords dont match, Confirm password: <This newline is also TelnetClient
added :)>
$ <here my confirm shows up>
Command not found...

The fun part is that if I run /usr/bin/telnet instead of TelnetClient
>From Java, no extra newlines are added. Explain that someone... Is 
The java application negotiating itself towards the blackbox as a 
Windows box, but my linux and solaris boxes /usr/bin/telnet negotiates as
Non Windows or what...

BR

/Daniel

-----Ursprungligt meddelande-----
Från: Michael Erskine [mailto:michael.erskine@ketech.com] 
Skickat: den 11 december 2006 13:54
Till: commons-user@jakarta.apache.org
Ämne: Re: TelnetClient problem?


On Monday 11 December 2006 06:18, Daniel Wikman wrote:
> '\r\n' is in
> fact a windowze construct, and I operate mostly on solaris/linux but 
> also of course on windows. Shouldn't this be made configurable???

CR LF is also a telnet construct - see RFC854

Regards,
Michael Erskine.

-- 
If you're going to do something tonight that you'll be sorry for tomorrow
morning, sleep late.
		-- Henny Youngman


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: TelnetClient problem?

Posted by Michael Erskine <mi...@ketech.com>.
On Monday 11 December 2006 06:18, Daniel Wikman wrote:
> '\r\n' is in
> fact a windowze construct, and I operate mostly on solaris/linux but also
> of course on
> windows. Shouldn't this be made configurable???

CR LF is also a telnet construct - see RFC854

Regards,
Michael Erskine.

-- 
If you're going to do something tonight that you'll be sorry for tomorrow
morning, sleep late.
		-- Henny Youngman


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: TelnetClient problem?

Posted by Daniel Wikman <da...@hotmail.com>.
Ummm, ohhh, seems like I will have problems doing that... Since the __output 
is
private simply overriding _connectAction_ does not do the trick, i need to 
modify
the existing stuff which I do not want to. Rory, isn't it in the products 
own interest
to be able to communicate with all possible nodes no matter of platform? 
'\r\n' is in
fact a windowze construct, and I operate mostly on solaris/linux but also of 
course on
windows. Shouldn't this be made configurable???

BR

/Daniel


>From: "Daniel Wikman" <da...@hotmail.com>
>Reply-To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
>To: commons-user@jakarta.apache.org
>Subject: Re: TelnetClient problem?
>Date: Sat, 09 Dec 2006 17:04:07 +0100
>
>
>Got it! Exellent answer, I'll have a look at it again, now I am using 
>ProcessBuilder instead,
>since that works..., but using a library feels safer...
>
>
>BR
>
>/Daniel
>
>>From: Rory Winston <rw...@eircom.net>
>>Reply-To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
>>To: Jakarta Commons Users List <co...@jakarta.apache.org>,  
>>dannewikman@hotmail.com
>>Subject: Re: TelnetClient problem?
>>Date: Tue, 05 Dec 2006 23:35:36 +0000
>>
>>Hi Daniel
>>
>>This is handled in TelnetClient::_connectAction(). The output stream is 
>>wrapped in a ToNetASCIIOutputStream, which replaces all \n with \r\n. A 
>>quick fix for your serial blackbox system may (I havent tried this) be to 
>>replace the line
>>
>>__output = new ToNetASCIIOutputStream(new TelnetOutputStream(this));
>>
>>with
>>
>>__output = new BufferedOutputStream(new TelnetOutputStream(this));
>>
>>
>>
>>protected void _connectAction_() throws IOException
>>    {
>>        super._connectAction_();
>>        InputStream input;
>>        TelnetInputStream tmp;
>>
>>        if (FromNetASCIIInputStream.isConversionRequired())
>>            input = new FromNetASCIIInputStream(_input_);
>>        else
>>            input = _input_;
>>
>>
>>        tmp = new TelnetInputStream(input, this, readerThread);
>>        if(readerThread)
>>        {
>>            tmp._start();
>>        }
>>      .....
>>        __input = new BufferedInputStream(tmp);
>>        __output = new ToNetASCIIOutputStream(new 
>>TelnetOutputStream(this));
>>    }
>>
>>We could make this configurable in some way if necessary.
>>Rory
>>
>>Daniel Wikman wrote:
>>>Hi all!
>>>
>>>I wonder if someone has seen this and know a "cure" for this behaviour. I 
>>>wrote a program based on the commons.net TelnetClient class. When using 
>>>the program towards a Unix or Linux box directly everything works fine, 
>>>but when using telnet towards a serial blackbox, I always get an extra 
>>>newline added when writing commands (it seems like TelnetClient or the 
>>>underlying stream makes line terminations a la windows... The fun part is 
>>>that if I make my own TelnetClient program based on 
>>>Java.util.ProcessBuilder it works just fine. I'd really like to make my 
>>>program independent of the "/usr/bin/telnet" to make it work on windows 
>>>platform as well. Does anyone know what option that controls this in 
>>>TelnetClient?
>>>
>>>BR
>>>
>>>/Daniel
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>
>_________________________________________________________________
>Facklor och eldar i trädgården http://alltombostad.msn.se/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>

_________________________________________________________________
Fynda charter till solen http://www.msn.se/resor/


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: TelnetClient problem?

Posted by Daniel Wikman <da...@hotmail.com>.
Got it! Exellent answer, I'll have a look at it again, now I am using 
ProcessBuilder instead,
since that works..., but using a library feels safer...


BR

/Daniel

>From: Rory Winston <rw...@eircom.net>
>Reply-To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
>To: Jakarta Commons Users List <co...@jakarta.apache.org>,  
>dannewikman@hotmail.com
>Subject: Re: TelnetClient problem?
>Date: Tue, 05 Dec 2006 23:35:36 +0000
>
>Hi Daniel
>
>This is handled in TelnetClient::_connectAction(). The output stream is 
>wrapped in a ToNetASCIIOutputStream, which replaces all \n with \r\n. A 
>quick fix for your serial blackbox system may (I havent tried this) be to 
>replace the line
>
>__output = new ToNetASCIIOutputStream(new TelnetOutputStream(this));
>
>with
>
>__output = new BufferedOutputStream(new TelnetOutputStream(this));
>
>
>
>protected void _connectAction_() throws IOException
>    {
>        super._connectAction_();
>        InputStream input;
>        TelnetInputStream tmp;
>
>        if (FromNetASCIIInputStream.isConversionRequired())
>            input = new FromNetASCIIInputStream(_input_);
>        else
>            input = _input_;
>
>
>        tmp = new TelnetInputStream(input, this, readerThread);
>        if(readerThread)
>        {
>            tmp._start();
>        }
>      .....
>        __input = new BufferedInputStream(tmp);
>        __output = new ToNetASCIIOutputStream(new 
>TelnetOutputStream(this));
>    }
>
>We could make this configurable in some way if necessary.
>Rory
>
>Daniel Wikman wrote:
>>Hi all!
>>
>>I wonder if someone has seen this and know a "cure" for this behaviour. I 
>>wrote a program based on the commons.net TelnetClient class. When using 
>>the program towards a Unix or Linux box directly everything works fine, 
>>but when using telnet towards a serial blackbox, I always get an extra 
>>newline added when writing commands (it seems like TelnetClient or the 
>>underlying stream makes line terminations a la windows... The fun part is 
>>that if I make my own TelnetClient program based on 
>>Java.util.ProcessBuilder it works just fine. I'd really like to make my 
>>program independent of the "/usr/bin/telnet" to make it work on windows 
>>platform as well. Does anyone know what option that controls this in 
>>TelnetClient?
>>
>>BR
>>
>>/Daniel
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>

_________________________________________________________________
Facklor och eldar i trädgården http://alltombostad.msn.se/


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: TelnetClient problem?

Posted by Rory Winston <rw...@eircom.net>.
Hi Daniel

This is handled in TelnetClient::_connectAction(). The output stream is 
wrapped in a ToNetASCIIOutputStream, which replaces all \n with \r\n. A 
quick fix for your serial blackbox system may (I havent tried this) be 
to replace the line

__output = new ToNetASCIIOutputStream(new TelnetOutputStream(this));

with

__output = new BufferedOutputStream(new TelnetOutputStream(this));



protected void _connectAction_() throws IOException
    {
        super._connectAction_();
        InputStream input;
        TelnetInputStream tmp;

        if (FromNetASCIIInputStream.isConversionRequired())
            input = new FromNetASCIIInputStream(_input_);
        else
            input = _input_;


        tmp = new TelnetInputStream(input, this, readerThread);
        if(readerThread)
        {
            tmp._start();
        }
      .....
        __input = new BufferedInputStream(tmp);
        __output = new ToNetASCIIOutputStream(new TelnetOutputStream(this));
    }

We could make this configurable in some way if necessary.
Rory

Daniel Wikman wrote:
> Hi all!
>
> I wonder if someone has seen this and know a "cure" for this behaviour. I wrote a program based 
> on the commons.net TelnetClient class. When using the program towards a Unix or Linux box 
> directly everything works fine, but when using telnet towards a serial blackbox, I always get an 
> extra newline added when writing commands (it seems like TelnetClient or the underlying stream 
> makes line terminations a la windows... The fun part is that if I make my own TelnetClient program 
> based on Java.util.ProcessBuilder it works just fine. I'd really like to make my program independent 
> of the "/usr/bin/telnet" to make it work on windows platform as well. Does anyone know what 
> option that controls this in TelnetClient? 
>
> BR
>
> /Daniel 
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org