de.mud.telnet
public class TelnetWrapper extends Wrapper
TelnetWrapper telnet = new TelnetWrapper(); try { telnet.connect(args[0], 23); telnet.login("user", "password"); telnet.setPrompt("user@host"); telnet.waitfor("Terminal type?"); telnet.send("dumb"); System.out.println(telnet.send("ls -l")); } catch(java.io.IOException e) { e.printStackTrace(); }Please keep in mind that the password is visible for anyone who can download the class file. So use this only for public accounts or if you are absolutely sure nobody can see the file.
Maintainer: Matthias L. Jugel
Modifier and Type | Field and Description |
---|---|
protected TelnetProtocolHandler |
handler |
Constructor and Description |
---|
TelnetWrapper() |
Modifier and Type | Method and Description |
---|---|
void |
connect(java.lang.String host,
int port)
Connect the socket and open the connection.
|
TelnetProtocolHandler |
getHandler() |
int |
read(byte[] b)
Read data from the socket and use telnet negotiation before returning
the data read.
|
java.lang.String |
send(java.lang.String cmd)
Send a command to the remote host.
|
disconnect, getPrompt, getTerminalType, getWindowSize, login, setLocalEcho, setPrompt, waitfor, waitfor, write
protected TelnetProtocolHandler handler
public TelnetProtocolHandler getHandler()
public void connect(java.lang.String host, int port) throws java.io.IOException
Wrapper
public java.lang.String send(java.lang.String cmd) throws java.io.IOException