|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.mindbright.ssh2.SSH2ConsoleRemote
This class implements a console to a remote command or shell. The underlying
mechanism is a session channel which is created on demand from the provided
connection layer. It can be used to execute single commands and/or control
input/output to/from a shell. It is for example extended to control an SCP1
client in the class SSH2SCP1Client.
To create a SSH2ConsoleRemote instance a complete connected ssh2
stack is needed from which one provides the SSH2Connection to
the constructor.
SSH2Connection,
SSH2SimpleClient| Field Summary | |
protected SSH2Connection |
connection
|
protected SSH2SessionChannel |
session
|
protected java.io.OutputStream |
stderr
|
protected java.io.OutputStream |
stdout
|
| Constructor Summary | |
SSH2ConsoleRemote(SSH2Connection connection)
Basic constructor. |
|
SSH2ConsoleRemote(SSH2Connection connection,
java.io.OutputStream stdout,
java.io.OutputStream stderr)
Constructor to be used to preset the stdout and/or stderr output streams to which the correspondings streams should be redirected to (i.e. |
|
| Method Summary | |
void |
changeStdOut(java.io.OutputStream out)
Changes the output stream where stdout is written to in the underlying session channel. |
void |
close()
Closes the session channel (i.e. |
boolean |
command(java.lang.String command)
Runs single command on server. |
boolean |
command(java.lang.String command,
java.io.OutputStream stdout)
Runs single command on server and redirects stdout to the given OutputStream. |
boolean |
command(java.lang.String command,
java.io.OutputStream stdout,
java.io.OutputStream stderr)
Runs single command on server and redirects stdout to the given OutputStream. |
java.io.OutputStream |
getStdIn()
Gets the stdin stream of the underlying session channel. |
java.io.InputStream |
getStdOut()
Gets the stdout stream of the underlying session channel. |
boolean |
shell()
Starts an interactive shell on the server, note that no PTY is allocated. |
boolean |
shell(boolean pty)
Starts an interactive shell on the server. |
boolean |
terminal(SSH2TerminalAdapter termAdapter)
|
int |
waitForExitStatus()
Retrieves the exit status reported by the command/shell run. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected SSH2Connection connection
protected SSH2SessionChannel session
protected java.io.OutputStream stdout
protected java.io.OutputStream stderr
| Constructor Detail |
public SSH2ConsoleRemote(SSH2Connection connection)
connection - connected connection layer
public SSH2ConsoleRemote(SSH2Connection connection,
java.io.OutputStream stdout,
java.io.OutputStream stderr)
command() method).
connection - connected connection layerstdout - the output stream to redirect stdout to (can be null)stderr - the output stream to redirect stderr to (can be null)| Method Detail |
public boolean command(java.lang.String command)
command in interface SSHConsoleRemotecommand - command line to run
public boolean command(java.lang.String command,
java.io.OutputStream stdout)
OutputStream.
command - command line to runstdout - the output stream to redirect stdout to
public boolean command(java.lang.String command,
java.io.OutputStream stdout,
java.io.OutputStream stderr)
OutputStream. This method also redirects stderr to the given
OutputStream.
command - command line to runstdout - the output stream to redirect stdout to (can be null)stderr - the output stream to redirect stderr to (can be null)
public boolean shell()
shell in interface SSHConsoleRemotepublic boolean shell(boolean pty)
pty
indicates whether to allocate a PTY or not.
pty - indicates whether to allocate a PTY or not
public boolean terminal(SSH2TerminalAdapter termAdapter)
public int waitForExitStatus()
close()) in which case
the status returned will be -1.
public void close()
close in interface SSHConsoleRemotepublic void changeStdOut(java.io.OutputStream out)
changeStdOut in interface SSHConsoleRemoteout - new stdout streampublic java.io.InputStream getStdOut()
getStdOut in interface SSHConsoleRemotepublic java.io.OutputStream getStdIn()
getStdIn in interface SSHConsoleRemote
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||