Thanks Daniel, I tried that and still no joy, but I think that I see the issue now.
Upon inspecting the traces that work vs. my own I see a very sharp difference. The server sends back: Command: Do Authentication Option Command: Will Echo Command: Will Suppress Go Ahead Command: Do New Environment Option Command: Do Negotiate About Window Size Command: Do Binary Transmission Command: Will Binary Transmission It is expecting: (based on the trace that works) Command: Won't Authentication Option But instead I am sending it the username right away. How do I send the "Won't Authenticate Option" command? I think this requires the use of a TelnetCommand and TelnetOption, but I am unsure of the format. Jason Dorsey | Engineering Intern -----Original Message----- From: Daniel Pitts [mailto:[email protected]] Sent: Wednesday, October 12, 2011 10:29 AM To: Commons Users List Cc: [email protected] Subject: Re: Telnet: Problems automating a session Try calling outputStream.flush() after each command. Thanks, Daniel. Sent from my iPhone On Oct 12, 2011, at 8:23 AM, Jason Dorsey <[email protected]> wrote: > 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 > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
