SocketTools .NET Edition

RshClient.Execute Method (String, Int32, String, String, String)

Execute the specified command on the remote host.

[Visual Basic]
Overloads Public Function Execute( _
   ByVal hostName As String, _
   ByVal hostPort As Integer, _
   ByVal userName As String, _
   ByVal userPassword As String, _
   ByVal command As String _
) As Boolean
[C#]
public bool Execute(
   string hostName,
   int hostPort,
   string userName,
   string userPassword,
   string command
);

Parameters

hostName
A string which specifies the name of the server to connect to. The string may either be an IP address or a fully qualified domain name.
hostPort

An integer value which specifies the port number to connect to. This method may be used to either connect to the rexec service or the rshell service, and which service is selected depends on the port number provided. One of the following values should be used:

Port Description
rshPortExec A connection is established with the server using port 512, the rexec service. This service requires that the client provide a username and password to execute the specified command.
rshPortShell A connection is established with the server using port 514, the rshell service. This service uses host equivalence to authenticate the user. With host equivalence, the remote server considers the client to be equivalent to itself, and as long as the specified user exists on the remote host, the client is permitted to execute commands on behalf of the user without requiring a password. Host equivalence is configured by the server administrator.
userName
A string which specifies the username which used to authenticate the client session.
userPassword
A string which specifies the password to be used to authenticate the user. A password is only used if the client is connecting to the rexec service. The rshell service uses host equivalence to authenticate the user and this argument will be ignored.
command
An string which specifies the command to be executed on the server.

Return Value

A boolean value which specifies if the connection has been established. If the socket is in blocking mode, a return value of true indicates that the connection has completed and the application may send and receive data from the remote host. If the client is in non-blocking mode, a return value of true indicates that the socket has been successfully created and the connection is in progress.

When a non-blocking connection has completed, the OnConnect event will be fired. If this method returns false, the connection could not be established and the application should check the value of the LastError property to determine the cause of the failure.

Remarks

The Execute method executes the specified command on a remote host. Output from the command may be read using the Read method. Input can be supplied to the program using the Write method. To search for a specific sequence of bytes in the output returned by the server, use the Search method.

The value of the Timeout property specifies the timeout period. The value of the Options property specifies the options that will be used when establishing the connection.

See Also

RshClient Class | SocketTools Namespace | RshClient.Execute Overload List