|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.mud.telnet.TelnetProtocolHandler | +--de.mud.telnet.TelnetWrapper
The telnet wrapper is a sample class for how to use the telnet protocol handler of the JTA source package. To write a program using the wrapper you may use the following piece of code as an example:
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
Field Summary | |
protected java.lang.String |
host
|
protected java.io.InputStream |
in
|
protected java.io.OutputStream |
out
|
protected int |
port
|
protected java.util.Vector |
script
|
protected ScriptHandler |
scriptHandler
|
protected java.net.Socket |
socket
|
Fields inherited from class de.mud.telnet.TelnetProtocolHandler |
ID |
Constructor Summary | |
TelnetWrapper()
|
Method Summary | |
void |
connect(java.lang.String host,
int port)
Connect the socket and open the connection. |
void |
disconnect()
Disconnect the socket and close the connection. |
java.lang.String |
getTerminalType()
Get the current terminal type for TTYPE telnet option. |
java.awt.Dimension |
getWindowSize()
Get the current window size of the terminal for the NAWS telnet option. |
void |
login(java.lang.String user,
java.lang.String pwd)
Login into remote host. |
void |
notifyEndOfRecord()
sent on IAC EOR (prompt terminator for remote access systems). |
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. |
void |
setLocalEcho(boolean echo)
Set the local echo option of telnet. |
void |
setPrompt(java.lang.String prompt)
|
java.lang.String |
waitfor(java.lang.String match)
|
java.lang.String |
waitfor(java.lang.String[] searchElements)
Wait for a string to come from the remote host and return all that characters that are received until that happens (including the string being waited for). |
void |
write(byte[] b)
Write data to the socket. |
Methods inherited from class de.mud.telnet.TelnetProtocolHandler |
inputfeed, negotiate, reset, sendTelnetControl, setCR, setCRLF, startup, transpose |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ScriptHandler scriptHandler
protected java.io.InputStream in
protected java.io.OutputStream out
protected java.net.Socket socket
protected java.lang.String host
protected int port
protected java.util.Vector script
Constructor Detail |
public TelnetWrapper()
Method Detail |
public void connect(java.lang.String host, int port) throws java.io.IOException
public void disconnect() throws java.io.IOException
public void notifyEndOfRecord()
notifyEndOfRecord
in class TelnetProtocolHandler
public void login(java.lang.String user, java.lang.String pwd) throws java.io.IOException
user
- the user namepwd
- the passwordpublic void setPrompt(java.lang.String prompt)
public java.lang.String send(java.lang.String cmd) throws java.io.IOException
cmd
- the commandpublic java.lang.String waitfor(java.lang.String[] searchElements) throws java.io.IOException
match
- the string to look forpublic java.lang.String waitfor(java.lang.String match) throws java.io.IOException
public int read(byte[] b) throws java.io.IOException
b
- the input buffer to read inpublic void write(byte[] b) throws java.io.IOException
write
in class TelnetProtocolHandler
b
- the buffer to be writtenpublic java.lang.String getTerminalType()
TelnetProtocolHandler
getTerminalType
in class TelnetProtocolHandler
de.mud.telnet.TelnetProtocolHandler
public java.awt.Dimension getWindowSize()
TelnetProtocolHandler
getWindowSize
in class TelnetProtocolHandler
de.mud.telnet.TelnetProtocolHandler
public void setLocalEcho(boolean echo)
TelnetProtocolHandler
setLocalEcho
in class TelnetProtocolHandler
de.mud.telnet.TelnetProtocolHandler
echo
- true for local echo, false for no local echo
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |