Forum: Ruby Run ruby script remotely

76841a063077b64ab9e9856841e22dda?d=identicon&s=25 Focon Rubix (mohamed_e)
on 2014-04-22 02:21
Hi,
I have a ruby script which I tested locally on my machine,
I want to execute it on three remote servers, Is there a way to execute
it remotely without connecting to every machine and executing it
Or Can I use a master server to run the script on the three machines, by
connecting to only one server

rgds
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-04-22 23:45
There isn't really enough information here to venture an opinion.

Do the remote servers have ruby installed? Does the script need to be
run on the machine, or can it do what it needs to do across the network
(e.g. update a shared folder)? What O/S are these servers running? Do
you intend to run this script on a schedule, or on demand? How are these
machines networked?
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-04-23 00:05
Focon Rubix wrote in post #1143709:

> I want to execute it on three remote servers,
> Can I use a master server to run the script on the three machines, by
> connecting to only one server



on linux and co, you can use dsh (distributed shell)
"
Doing
> dsh -g children -c -- uname -a

will execute programs on group "children", which is specified in
${HOME}/.dsh/group/children

http://www.netfort.gr.jp/~dancer/software/dsh.html.en
76841a063077b64ab9e9856841e22dda?d=identicon&s=25 Focon Rubix (mohamed_e)
on 2014-04-25 10:48
Joel Pearson wrote in post #1143804:
> There isn't really enough information here to venture an opinion.
>
> Do the remote servers have ruby installed?
Yes ruby is installed on every server


> Does the script need to be run on the machine, or can it do what it needs to do
across the network

the server has to be run on the machine, generally I ssh the machine I
navigate to its diectory and then run it: ruby script.rb

> (e.g. update a shared folder)? What O/S are these servers running?
I have ubuntu installed on every server

> Do you intend to run this script on a schedule, or on demand?
Mainly, on demand
> How are these machines networked?
I am using a cloud server, servers are in a vps


Thank for answering me,answers in line
If there is no other solution I am considering the solution of raubarede
Else I found gearman but I think I have to learn it first and I have to
change a little bit my code


rgds,
45232ee28a5464660509e820cc73fb21?d=identicon&s=25 Montana Burr (moonman239)
on 2014-04-27 01:09
Focon Rubix wrote in post #1143709:
> Is there a way to execute
> it remotely without connecting to every machine and executing it

By that, do you mean you want all three servers to run the scripts
simultaneously, or are you OK with a program on your computer telling
one server at a time to run the scripts?

Either way, the task can easily be done using a Ruby script that is run
on your machine.  If you want the scripts run by one server at a time,
create a Ruby script that tells the virtual machine to connect to one
server, tell it to run the script, then drop the connection and repeat
with the other two servers. If, however, you want the scripts run
simultaneously, just create a Ruby script that tells the virtual machine
on your computer to create one thread per server and use them to connect
to any server and tell it to run the scripts you want it to run.
76841a063077b64ab9e9856841e22dda?d=identicon&s=25 Focon Rubix (mohamed_e)
on 2014-04-28 14:19
the second solution will be great for me, no need for simultaneous
execution on different servers
I am OK with a program on my computer telling one server at a time to
run the scripts

How can I do that, is there a gem for this?
can you give an example of script executing locally and firing a script
remotely
I am able to deploy it with capistrano on all servers but what to do
after that?


rgds
45232ee28a5464660509e820cc73fb21?d=identicon&s=25 Montana Burr (moonman239)
on 2014-05-08 01:32
Focon Rubix wrote in post #1144302:
> the second solution will be great for me, no need for simultaneous
> execution on different servers
> I am OK with a program on my computer telling one server at a time to
> run the scripts
>
> How can I do that, is there a gem for this?
> can you give an example of script executing locally and firing a script
> remotely
> I am able to deploy it with capistrano on all servers but what to do
> after that?
>
>
> rgds

If you can SSH into each of the servers, then you can use the Net::SSH
library to tell the virtual machine on the servers to run a script.

This shell command works for running any script:
"ruby", followed by a space and the full path to the script.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.