I want to connect to system2, then invoke ruby and execute a ruby
script.
say I’ve a sample script in system2 as sample.rb.
I want to run that from system1.
Please let me know how I would do that.
Look into ssh.
You can run the ssh client directly it using system [vlad does this], or
you can use the Net::SSH gem [capistrano does this]
Of course, you need a working ssh daemon on system2. With Unix/Linux
you’ll have this out of the box. For Windows look at installing cygwin.
ssh is well tested and secure.
Less secure alternative: write your script sample.rb on system 2 such
that it waits for a connection on a TCP socket and then does its stuff.
The class GServer in the standard library may help you, or read up on
DRb.