Remotely executes a command through the rshd daemon on the server to which the RCommandClient is connected. After calling this method, you may interact with the remote process through its standard input, output, and error streams. You will typically be able to detect the termination of the remote process after reaching end of file on its standard output (accessible through
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 RCommandClient, providing an independent stream through which standard error will be transmitted. The local socket must originate from a secure port (512 - 1023), and rcommand() ensures that this will be so. RCommandClient will also 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 behavior with setRemoteVerificationEnabled().
@param localUsername The user account on the local machine that isrequesting the command execution.
@param remoteUsername The account name on the server through which toexecute the command.
@param command The command, including any arguments, to execute.
@param separateErrorStream True if you would like the standard errorto be transmitted through a different stream than standard output. False if not.
@exception IOException If the rcommand() attempt fails. The exceptionwill contain a message indicating the nature of the failure.