Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Telnet Client using java  RSS feed

 
Prasanna Venkatesh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I am trying to implement Telnet client using Apache common telnet library .

I am trying to connect to telnet server and try to execute some commands over there server ...
Actually I am able to send the user name and when I am sending password, though I send carriage return and new line character at the end of password ,I am getting timeout error from the server . Any suggestion on this ??



This is the code I use to send user name and password . Where

out - outputstream to telnetserver
UserCommand - Password

Thanks and Regards
Prasanna
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest wrapping the OutputStream in a PrintWriter. Then you can just println() your commands.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you can just println() your commands.

You really shouldn't: Don't println to a socket
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I never knew that. That still leaves print() as usefull, with a hardcoded \r\n at the end of each command.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!