|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.mud.jta.Wrapper
public class Wrapper
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
|
Constructor Summary | |
---|---|
Wrapper()
|
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 |
getPrompt()
|
java.lang.String |
getTerminalType()
|
java.awt.Dimension |
getWindowSize()
|
void |
login(java.lang.String user,
java.lang.String pwd)
Login into remote host. |
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)
|
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 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 Wrapper()
Method Detail |
---|
public void connect(java.lang.String host, int port) throws java.io.IOException
java.io.IOException
public void disconnect() throws java.io.IOException
java.io.IOException
public void login(java.lang.String user, java.lang.String pwd) throws java.io.IOException
user
- the user namepwd
- the password
java.io.IOException
public void setPrompt(java.lang.String prompt)
public java.lang.String getPrompt()
public java.lang.String send(java.lang.String cmd) throws java.io.IOException
cmd
- the command
java.io.IOException
public java.lang.String waitfor(java.lang.String[] searchElements) throws java.io.IOException
match
- the string to look for
java.io.IOException
public java.lang.String waitfor(java.lang.String match) throws java.io.IOException
java.io.IOException
public int read(byte[] b) throws java.io.IOException
b
- the input buffer to read in
java.io.IOException
public void write(byte[] b) throws java.io.IOException
b
- the buffer to be written
java.io.IOException
public java.lang.String getTerminalType()
public java.awt.Dimension getWindowSize()
public void setLocalEcho(boolean echo)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |