![]() |
![]() |
#1 (permalink) |
Crazy
|
Telnet and Java
yoyo,
I am writing an application in Java that connects to a router via telnet and runs a script of commands and captures the output. A lot of dudes on the web say the telnet protocol is ugly and to use someone else's implementation, which is good, but I can't find a good implementation. All I need is connect, login with stored username ![]() |
![]() |
![]() |
#2 (permalink) |
Tilted
|
I would suspect that the router is nothing more than a straight raw TCP/IP connection -- similar to using telnet to connect to a POP or SMTP server or even HTTP. I would first use something like Ethereal to trace the connection and see what data goes back and forth, probably straight ASCII text -- nothing binary. If that is all it is you can simply use java to connect to the system and write some data (send the appropriate command). Then just read data until you receive some "end-of-line" token. Make sure you get the end-of-line characters correct, because some protocols will interpret them differently.
I suspect all you really need is Socket(InetAddress, port) Socket.getOutputStream() - for sending the commands Socket.getInputStream() - for receiving the output Last edited by a-j; 02-16-2005 at 11:06 PM.. |
![]() |
![]() |
#3 (permalink) |
I am Winter Born
Location: Alexandria, VA
|
I agree with a-j: telnet is nothing more than passing pure text messages back and forth (such as "connect 192.168.0.1"). You should easily be able to tell Java to open a socket, dump some text into the socket, wait for the reply, display it, repeat as necessary.
|
![]() |
Tags |
java, telnet |
|
|