com.mindbright.ssh
public class SSHConsoleClient extends SSHClientUserAdaptor implements SSHConsole, SSHConsoleRemote
| Modifier and Type | Field and Description |
|---|---|
protected SSHClient |
client |
static int |
DEFAULT_COPY_BUFFER_SZ |
protected OutputStreamPipe |
inBottom |
protected InputStreamPipe |
inTop |
protected SSHClientUser |
proxyUser |
protected java.io.OutputStream |
stderr
Where to store standard error bytes.
|
protected com.mindbright.ssh.SSHConsoleClient.TerminalOutStream |
stdin |
protected java.io.OutputStream |
stdout |
interactor, sshHost, sshPort| Constructor and Description |
|---|
SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor) |
SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor,
int bufferSize) |
SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor,
SSHClientUser user) |
SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor,
SSHClientUser user,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
changeStdErr(java.io.OutputStream err)
Where to store standard error bytes.
|
void |
changeStdOut(NonBlockingOutput out)
Changes the output stream where stdout is written to in the underlying
session channel.
|
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.
|
void |
close(boolean waitforcloseconfirm)
Closes the session channel.
|
boolean |
command(java.lang.String command)
Runs single command on server.
|
int |
command(java.lang.String command,
long timeout)
Send a command and wait for a given timeout for the it to finish.
|
java.lang.Exception |
getException() |
NonBlockingOutput |
getNBStdIn()
Gets the stdin stream of the underlying session channel.
|
NonBlockingInput |
getNBStdOut()
Gets the stdout stream of the underlying session channel.
|
NetworkConnection |
getProxyConnection()
Return a connection to the server.
|
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.
|
TerminalWindow |
getTerminal() |
void |
print(java.lang.String str) |
void |
println(java.lang.String str) |
void |
serverConnect(SSHChannelController controller,
SSHCipher sndCipher) |
void |
serverDisconnect(java.lang.String reason) |
void |
setClientUser(SSHClientUser proxyUser) |
boolean |
shell()
Starts an interactive shell on the server, note that no PTY is
allocated.
|
void |
stderrWriteString(byte[] str) |
void |
stdoutWriteString(byte[] str) |
boolean |
wantPTY()
Return true if we need a PTY on the server
|
getAliveInterval, getCompressionLevel, getConnectTimeout, getDisplay, getHelloTimeout, getInteractor, getKexTimeout, getMaxPacketSz, getSrvHost, getSrvPort, wantX11Forwardpublic static final int DEFAULT_COPY_BUFFER_SZ
protected SSHClient client
protected SSHClientUser proxyUser
protected InputStreamPipe inTop
protected OutputStreamPipe inBottom
protected java.io.OutputStream stdout
protected com.mindbright.ssh.SSHConsoleClient.TerminalOutStream stdin
protected java.io.OutputStream stderr
public SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor,
SSHClientUser user)
throws java.io.IOException
java.io.IOExceptionpublic SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor)
throws java.io.IOException
java.io.IOExceptionpublic SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic SSHConsoleClient(java.lang.String sshHost,
int port,
SSHAuthenticator authenticator,
SSHInteractor interactor,
SSHClientUser user,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.Exception getException()
public boolean command(java.lang.String command)
SSHConsoleRemoteNote, this will create an extra pair of threads to handle the data.
command in interface SSHConsoleRemotecommand - command line to runpublic int command(java.lang.String command,
long timeout)
throws TimeoutException,
java.io.IOException
TimeoutExceptionjava.io.IOExceptionpublic boolean shell()
SSHConsoleRemoteshell in interface SSHConsoleRemotepublic void close()
SSHConsoleRemoteclose in interface SSHConsoleRemotepublic void close(boolean waitforcloseconfirm)
SSHConsoleRemoteclose in interface SSHConsoleRemotepublic void changeStdOut(java.io.OutputStream out)
SSHConsoleRemoteNote that this method only works if the underlying session uses blocking streams and threads.
changeStdOut in interface SSHConsoleRemoteout - new stdout streampublic void changeStdErr(java.io.OutputStream err)
public java.io.OutputStream getStdIn()
SSHConsoleRemoteNote that this method returns null if the underlying stream uses non-blocking io
getStdIn in interface SSHConsoleRemotepublic java.io.InputStream getStdOut()
SSHConsoleRemoteNote that this method returns null if the underlying stream uses non-blocking io
getStdOut in interface SSHConsoleRemotepublic void changeStdOut(NonBlockingOutput out) throws java.lang.IllegalArgumentException
SSHConsoleRemoteNote that this method only works if the underlying session uses non-blocking io.
changeStdOut in interface SSHConsoleRemoteout - new stdout streamjava.lang.IllegalArgumentExceptionpublic NonBlockingOutput getNBStdIn()
SSHConsoleRemoteNote that this method returns null if the underlying stream uses blocking io
getNBStdIn in interface SSHConsoleRemotepublic NonBlockingInput getNBStdOut()
SSHConsoleRemoteNote that this method returns null if the underlying stream uses blocking io
getNBStdOut in interface SSHConsoleRemotepublic void setClientUser(SSHClientUser proxyUser)
public void stdoutWriteString(byte[] str)
stdoutWriteString in interface SSHConsolepublic void stderrWriteString(byte[] str)
stderrWriteString in interface SSHConsolepublic TerminalWindow getTerminal()
getTerminal in interface SSHConsolepublic void print(java.lang.String str)
print in interface SSHConsolepublic void println(java.lang.String str)
println in interface SSHConsolepublic void serverConnect(SSHChannelController controller, SSHCipher sndCipher)
serverConnect in interface SSHConsolepublic void serverDisconnect(java.lang.String reason)
serverDisconnect in interface SSHConsolepublic boolean wantPTY()
SSHClientUserwantPTY in interface SSHClientUserwantPTY in class SSHClientUserAdaptorpublic NetworkConnection getProxyConnection() throws java.io.IOException
SSHClientUsergetProxyConnection in interface SSHClientUsergetProxyConnection in class SSHClientUserAdaptorjava.io.IOException