commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dorsey <Jason.Dor...@netiq.com>
Subject Telnet: Problems automating a session
Date Wed, 12 Oct 2011 15:23:52 GMT
Hey,

Very new to java socket programming and I am having an issue with automating a session to
issue one command and then exit. When I use the commons telnet library I am able to connect
and successfully run the command, but only when I interact with the prompt. When I try and
simulate just issuing the commands it does not work. What seems to be happening is that instead
of writing each command as a separate packet, all the commands are being sent in the same
packet (validated this with wireshark).

What I have checked.


1.       The batch file does work locally on the system.

2.       The command does work when typed into a telnet session (validated with tcpview).

3.       The non-working version does connect to the remote system.

4.       The correct auth information is being passed to the function call.

Setup that works:


Just like the weather demo

My faulty setup:

Append the user, pass, command and exit strings with "\r\n". (user += "\r\n";)
And with each item I:
                Convert them into a ByteArrayInputStream (in = new ByteArrayInputStream(user.getBytes());)
                Invoke Util.copyStream (Util.copyStream(in, remoteOutput); ) // where remoteOutput
is the telnet's outputstream

Thanks

Jason Dorsey | Engineering Intern


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message