Executes a command on the Remote Host.
Namespace: Jscape.TelnetAssembly: Jscape.Telnet (in Jscape.Telnet.dll) Version: 2.6.1.0
Syntax
C# |
---|
public byte[] Execute( string hostname, int port, string username, string localUsername, string command ) |
Visual Basic |
---|
Public Function Execute ( _ hostname As String, _ port As Integer, _ username As String, _ localUsername As String, _ command As String _ ) As Byte() |
Visual C++ |
---|
public: array<unsigned char>^ Execute( String^ hostname, int port, String^ username, String^ localUsername, String^ command ) |
Parameters
- hostname
- Type: System..::..String
The hostname or IP address of the Remote Host.
- port
- Type: System..::..Int32
The Port of the Remote Host. Valid values are between 512 and 1023 inclusive. By default port 514 will be used.
- username
- Type: System..::..String
The username for the Remote Host.
- localUsername
- Type: System..::..String
The username for the Remote Host used to execute the command.
- command
- Type: System..::..String
The command to execute on the Remote Host.
Return Value
Result, as byte array, from Remote Host.
Examples
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.
CopyRsh Execute
CopyRsh Execute

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

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)