Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## examples
Class RemoteShellScript

    java.lang.Object
      examples.RemoteShellScript

All Implemented Interfaces:
  ExpectOutputStream.Expector

public class RemoteShellScript
extends java.lang.Object
implements ExpectOutputStream.Expector

This is a simple demo of running a list of command-lines given as text file. The commands are run sequentially and the stdout output from each command is printed to the local stdout (stderr is also redirected to the local stderr).

Usage: `java -cp examples.jar examples.RemoteShellScript server[:port] username password script_file`

See Also:
  `ExpectOutputStream`

Constructor Summary
`RemoteShellScript(SSH2ConsoleRemote console)` Constructor which takes the remote console where the script should be executed as argument.

Method Summary
`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

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RemoteShellScript

    public RemoteShellScript(SSH2ConsoleRemote console)

  Constructor which takes the remote console where the script should be executed as argument.

Parameters:
  `console` - connection to server

Method Detail

### run

    public java.lang.String run(java.lang.String cmd)

  Launch a single command on the server

  Parameters:
    `cmd` - command line to execute
  Returns:
    the output from the given command

### exit

    public void exit()

  Log off from server

### main

    public static void main(java.lang.String[] argv)

  Run the application

### reached

    public void reached(ExpectOutputStream out,
                        byte[] buf,
                        int len)

  Description copied from interface: `ExpectOutputStream.Expector`
  This function is called whenever the expected string is found in the data stream.

  Specified by:
    `reached` in interface `ExpectOutputStream.Expector`
  Parameters:
    `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.

### closed

    public void closed(ExpectOutputStream out,
                       byte[] buf,
                       int len)

  Description copied from interface: `ExpectOutputStream.Expector`
  This function is called when the data stream is closed.

  Specified by:
    `closed` in interface `ExpectOutputStream.Expector`
  Parameters:
    `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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD