Telnet Factory for .NET

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

Executes a command on the Remote Host.

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

Parameters

hostname
The hostname or IP address of the Remote Host.
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. Substitute a valid Remote Host, port, user, and local user for the hostname, port, username, and localuser parameters.

[C#]
Rsh rsh = new Rsh();            
byte[] response  = rsh.Execute("hostname", "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", "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