Telnet Factory for .NET

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

Executes a command on the Remote Host.

public byte[] Execute(
   string hostname,
   int port,
   string username,
   string localUsername,
   string command
);

Parameters

hostname
The hostname or IP address of the Remote Host.
port
The Port of the Remote Host. Valid values are between 512 and 1023 inclusive. By default port 514 will be used.
username
The username for the Remote Host.
localUsername
The username for the Remote Host used to execute the command.
command
The command to execute on the Remote Host.

Return Value

Result, as byte array, from Remote Host.

Example

This example returns the results of a directory listing command executed under root user on the Remote Host using port 1010. Substitute a valid Remote Host, user, and local user for the hostname, username, and localuser parameters.

[C#]
Rsh rsh = new Rsh();            
byte[] response  = rsh.Execute("hostname", 514, "username", "root", "ls -al");
string data = rsh.Encoding.GetString(response);            
Console.WriteLine(data);

[Visual Basic]
Private WithEvents rsh As Rsh
rsh = New Rsh
Dim response As Byte() = rsh.Execute("hostname", 514, "username", "root", "ls -al")
Dim data As String = rsh.Encoding.GetString(response)
Console.WriteLine(data)

See Also

Rsh Class | Jscape.Telnet Namespace | Rsh.Execute Overload List