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, wantX11Forward
public 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.IOException
public SSHConsoleClient(java.lang.String sshHost, int port, SSHAuthenticator authenticator, SSHInteractor interactor) throws java.io.IOException
java.io.IOException
public SSHConsoleClient(java.lang.String sshHost, int port, SSHAuthenticator authenticator, SSHInteractor interactor, int bufferSize) throws java.io.IOException
java.io.IOException
public SSHConsoleClient(java.lang.String sshHost, int port, SSHAuthenticator authenticator, SSHInteractor interactor, SSHClientUser user, int bufferSize) throws java.io.IOException
java.io.IOException
public java.lang.Exception getException()
public boolean command(java.lang.String command)
SSHConsoleRemote
Note, this will create an extra pair of threads to handle the data.
command
in interface SSHConsoleRemote
command
- command line to runpublic int command(java.lang.String command, long timeout) throws TimeoutException, java.io.IOException
TimeoutException
java.io.IOException
public boolean shell()
SSHConsoleRemote
shell
in interface SSHConsoleRemote
public void close()
SSHConsoleRemote
close
in interface SSHConsoleRemote
public void close(boolean waitforcloseconfirm)
SSHConsoleRemote
close
in interface SSHConsoleRemote
public void changeStdOut(java.io.OutputStream out)
SSHConsoleRemote
Note that this method only works if the underlying session uses blocking streams and threads.
changeStdOut
in interface SSHConsoleRemote
out
- new stdout streampublic void changeStdErr(java.io.OutputStream err)
public java.io.OutputStream getStdIn()
SSHConsoleRemote
Note that this method returns null if the underlying stream uses non-blocking io
getStdIn
in interface SSHConsoleRemote
public java.io.InputStream getStdOut()
SSHConsoleRemote
Note that this method returns null if the underlying stream uses non-blocking io
getStdOut
in interface SSHConsoleRemote
public void changeStdOut(NonBlockingOutput out) throws java.lang.IllegalArgumentException
SSHConsoleRemote
Note that this method only works if the underlying session uses non-blocking io.
changeStdOut
in interface SSHConsoleRemote
out
- new stdout streamjava.lang.IllegalArgumentException
public NonBlockingOutput getNBStdIn()
SSHConsoleRemote
Note that this method returns null if the underlying stream uses blocking io
getNBStdIn
in interface SSHConsoleRemote
public NonBlockingInput getNBStdOut()
SSHConsoleRemote
Note that this method returns null if the underlying stream uses blocking io
getNBStdOut
in interface SSHConsoleRemote
public void setClientUser(SSHClientUser proxyUser)
public void stdoutWriteString(byte[] str)
stdoutWriteString
in interface SSHConsole
public void stderrWriteString(byte[] str)
stderrWriteString
in interface SSHConsole
public TerminalWindow getTerminal()
getTerminal
in interface SSHConsole
public void print(java.lang.String str)
print
in interface SSHConsole
public void println(java.lang.String str)
println
in interface SSHConsole
public void serverConnect(SSHChannelController controller, SSHCipher sndCipher)
serverConnect
in interface SSHConsole
public void serverDisconnect(java.lang.String reason)
serverDisconnect
in interface SSHConsole
public boolean wantPTY()
SSHClientUser
wantPTY
in interface SSHClientUser
wantPTY
in class SSHClientUserAdaptor
public NetworkConnection getProxyConnection() throws java.io.IOException
SSHClientUser
getProxyConnection
in interface SSHClientUser
getProxyConnection
in class SSHClientUserAdaptor
java.io.IOException