Run ruby script remotely

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

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?

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

Joel P. 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,

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

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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs