Execute Method  
 

Execute the specified command on the server.

Syntax

object.Execute( [RemoteHost], [RemotePort], [UserName], [Password], [Command], [Timeout], [Options] )

Parameters

RemoteHost
A optional string argument which specifies the name of the server to connect to. The string may either be an IP address or a fully qualified domain name. If the argument is omitted, the value of the HostAddress or HostName property will be used.
RemotePort
An optional integer argument 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. If this argument is omitted, the value of the RemotePort property will be used.
Value Constant Description
512 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.
514 rshPortRshell 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 server considers the client to be equivalent to itself, and as long as the specified user exists on the server, 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
An optional string argument which specifies the username which used to authenticate the client session. If this argument is omitted, the value of the UserName property will be used.
Password
An optional string argument which specifies the password to be used to authenticate the user. If this argument is omitted, the value of the Password property will be used. 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 optional string argument which specifies the command to be executed on the server. If this argument is omitted, the value of the Command property will be used.
Timeout
An optional integer argument which specifies the number of seconds that the client will wait for a response from the server. If this argument is omitted, the value of the Timeout property will be used. This value is only used for synchronous connections where the Blocking property is set to True.
Options
An optional integer argument which specifies one or more connection options. This argument is reserved for future use and should be omitted.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The Execute method executes the specified command on a server. 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.

See Also

Disconnect Method, Login Method, Read Method, Search Method