Using the Rsh class

Top  Previous 

The Rsh class allows you to connect to a remote host and execute a command.

 

Note

 

Using the Rsh class differs from using the Rexec class in that the Rsh class is strictly based on a Remote Host authentication configuration while the Rexec class performs a full login.

 

 

Example

This example demonstrates executing a directory listing command on a remote host using the Rsh class.

 

[C#]

using Jscape.Telnet;

 

namespace RshTest {

 

 class RshExample {

 

         // The main entry point for the application.

         [STAThread]

         static void Main(string[] args) {

 

                 // Instantiate Rsh

                 Rsh rsh = new Rsh();

                 // connect to Remote Host and execute directory listing command

                 byte[] response = rsh.Execute("remotehost.com", "username", "ls -al");

 

                 // Get Remote Host response

                 string data = rsh.Encoding.GetString(response);

                 Console.WriteLine(data);

                 Console.WriteLine("Done.");

         }

 }

}

 

 

[Visual Basic]

Imports Jscape.Telnet

 

Module Module1

 

  Sub Main()

      ' Instantiate Rsh

      Dim myRsh As Rsh = New Rsh

 

      ' connect to Remote Host and execute directory listing command

      Dim response As Byte() = myRsh.Execute("remotehost.com", "username", "ls -al")

 

      ' Get Remote Host response

      Dim data As String = myRsh.Encoding.GetString(response)

       Console.WriteLine(data)

       Console.WriteLine("Done.")

 

  End Sub

 

End Module

 

 

See also

 

Remote Host authentication





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC