Shortcut Menu


Main Navigation

Choose your language

ActiveXperts Network Component Add network capabilities to any Windows or .NET application


Network Component - Rsh Object

RSh executes a command on a host. The remote hosts must run the RSh daemon. An RSh client utility is shipped with most operating systems these days. This RSh command line utility copies its standard input to the remote command, the standard output of the remote command to its standard output, and the standard error of the remote command to its standard error. Interrupt, quit and terminate signals are propagated to the remote command; rsh normally terminates when the remote command does.

The Network Component RSh object has the same functionality as the RSh command-line utility, except that it has no user interface by itself: standard error and standard output are not copied to the console, but are copied to the corresponding object properties (StdErr and StdOut) instead.

The Rsh object is part of the Network Component. Overview of all Network Component objects:

DnsServer & DnsRecord - Ftp & FtpFile - Http - Icmp - IPtoCountry - Msn - Ntp - Radius - Rsh - Scp - SFtp - Ssh - SnmpManager - SnmpTrapManager - SnmpMibBrowser - Tcp - Tftp - TraceRoute - Udp - Xen - Wake-on-LAN - Xen (Citrix)

Rsh Sample code

Visual Basic .NET sample: Execute a script on a remote LINUX machine using RSH

Imports AxNetwork

Module RShDemo
   Sub Main()
      Dim objRSh As RSh = New RSh
      Dim objConstants As SocketConstants = New SocketConstants


      objRSh.UserName      = "root"
      objRSh.Host          = ""
      objRSh.Command       = "/bin/ls"
      objRSh.ScriptTimeOut = 5000
      Console.WriteLine("Running command...")
      Console.WriteLine(" Result:" & objRSh.LastError.ToString())
      If (objRSh.LastError = 0) Then
         Console.WriteLine("StdErr:" & objRSh.StdErr)
         Console.WriteLine("StdOut:" & objRSh.StdOut)
      End If
    End Sub
End Module  

Visual C# .NET sample: Execute a script on a remote LINUX machine using RSH

using System; 
using AxNetwork;
   namespace RShDemo
      class RShDemo
         static void Main(string[] args)
            RSh objRSh = new RSh ();


            objRSh.Host          = "";
            objRSh.Command       = "/bin/ls";
            objRSh.ScriptTimeOut = 5000;
            Console.WriteLine( "Running command..." );
            Console.WriteLine( "Result:"+objRSh.LastError.ToString());
            if ( objRSh.LastError == 0 )
               Console.WriteLine( "StdOut:" + objRSh.StdOut );
               Console.WriteLine( "StdErr:" + objRSh.StdErr );
            Console.WriteLine( "Ready." );

On, you can find a lot of Network Component samples. These samples are also part of the Network Component installation.

» Visit