public class RExecClient extends SocketClient
As with virtually all of the client classes in org.apache.commons.net, this
class derives from SocketClient, inheriting its connection methods.
The way to use RExecClient is to first connect
to the server, call the
rexec() method, and then
fetch the connection's input, output, and optionally error streams.
Interaction with the remote command is controlled entirely through the
I/O streams. Once you have finished processing the streams, you should
disconnect() to clean up properly.
By default the standard output and standard error streams of the
remote process are transmitted over the same connection, readable
from the input stream returned by
getInputStream(). However, it is
possible to tell the rexecd daemon to return the standard error
stream over a separate connection, readable from the input stream
can specify that a separate connection should be created for standard
error by setting the boolean
The standard input of the remote process can be written to through
the output stream returned by
|Modifier and Type||Field and Description|
If a separate error stream is requested,
The default rexec port.
|Constructor and Description|
The default RExecClient constructor.
|Modifier and Type||Method and Description|
Disconnects from the server, closing all associated open sockets and streams.
Returns the InputStream from which the standard error of the remote process can be read if a separate error stream is requested from the server.
Returns the InputStream from which the standard output of the remote process can be read.
Returns the OutputStream through which the standard input of the remote process can be written.
Return whether or not verification of the remote host providing a separate error stream is enabled.
Remotely executes a command through the rexecd daemon on the server to which the RExecClient is connected.
Enable or disable verification that the remote host connecting to create a separate error stream is the same as the host to which the standard out stream is connected.
_connectAction_, addProtocolCommandListener, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getCharsetName, getCommandSupport, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
public static final int DEFAULT_PORT
public InputStream getInputStream()
public OutputStream getOutputStream()
public InputStream getErrorStream()
public void rexec(String username, String password, String command, boolean separateErrorStream) throws IOException
getInputStream(). Disconnecting from the server or closing the process streams before reaching end of file will not necessarily terminate the remote process.
If a separate error stream is requested, the remote server will
connect to a local socket opened by RExecClient, providing an
independent stream through which standard error will be transmitted.
RExecClient will do a simple security check when it accepts a
connection for this error stream. If the connection does not originate
from the remote server, an IOException will be thrown. This serves as
a simple protection against possible hijacking of the error stream by
an attacker monitoring the rexec() negotiation. You may disable this
username- The account name on the server through which to execute the command.
password- The plain text password of the user account.
command- The command, including any arguments, to execute.
separateErrorStream- True if you would like the standard error to be transmitted through a different stream than standard output. False if not.
IOException- If the rexec() attempt fails. The exception will contain a message indicating the nature of the failure.
public void rexec(String username, String password, String command) throws IOException
rexec(username, password, command, false);
username- the user name
password- the password
command- the command to run
IOException- if an error occurs
public void disconnect() throws IOException
public final void setRemoteVerificationEnabled(boolean enable)
enable- True to enable verification, false to disable verification.
public final boolean isRemoteVerificationEnabled()
Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.