examples
public class RemoteShellScript extends java.lang.Object implements ExpectOutputStream.Expector
Usage:
java -cp examples.jar examples.RemoteShellScript
server[:port] username password
script_file
ExpectOutputStream
Constructor and Description |
---|
RemoteShellScript(SSH2ConsoleRemote console)
Constructor which takes the remote console where the script
should be executed as argument.
|
Modifier and Type | Method and Description |
---|---|
void |
closed(ExpectOutputStream out,
byte[] buf,
int len)
This function is called when the data stream is closed.
|
void |
exit()
Log off from server
|
static void |
main(java.lang.String[] argv)
Run the application
|
void |
reached(ExpectOutputStream out,
byte[] buf,
int len)
This function is called whenever the expected string is
found in the data stream.
|
java.lang.String |
run(java.lang.String cmd)
Launch a single command on the server
|
public RemoteShellScript(SSH2ConsoleRemote console)
console
- connection to serverpublic java.lang.String run(java.lang.String cmd)
cmd
- command line to executepublic void exit()
public static void main(java.lang.String[] argv)
public void reached(ExpectOutputStream out, byte[] buf, int len)
ExpectOutputStream.Expector
reached
in interface ExpectOutputStream.Expector
out
- the stream this happened on.buf
- a buffer containing all the data which has been
seen on the stream since the last time
reached
was called. Note that the
buffer may be bigger than needed.len
- how many bytes of data there is in the buffer.public void closed(ExpectOutputStream out, byte[] buf, int len)
ExpectOutputStream.Expector
closed
in interface ExpectOutputStream.Expector
out
- the stream this happened on.buf
- a buffer containing all the data which has been
seen on the stream since the last time
reached
was called. Note that the
buffer may be bigger than needed.len
- how many bytes of data there is in the buffer.