murugu has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Im currently developing a script in which i need to run some commands in a remote machine. We are using ssh to connect to the remote machine.

This script will be run on any one of the 1000 clusters which are all load balanced. Iam unable to use the module Net::SSH module, why because installing the module in 1000 machines will be tedious job.

I dont know whether any module comes along with core distribution can do this. If so please let me know.

So as a workaround we are using expect for this purpose. But i want to do it using perl.

I peeked throught the module IPC::Session. It seems that its an independent module (i.e)it is not depending on any libraries other than the libraries which comes along with the core.

Is it possible for me to create a executable for the perl script which im developing along with the module IPC::Session, so that porting that executable to any machine in the cluster will do what i need(connect and execute commands in remote machine).

By the way Im using perl 5.6.1 under RH Linux. Please guide me with your suggestions.

Million thanks in advance.

Updated the heading

Regards,
Murugesan Kandasamy
use perl for(;;);

Replies are listed 'Best First'.
Re: Connecting Remote machines using perl.
by tirwhan (Abbot) on Dec 19, 2005 at 10:28 UTC

    If you're running this on a cluster node, don't you have some form of shared storage available to all nodes (even if it's just a minuscule ramdisk) you could use? You could install Net::SSH there and use lib the directory in order to avoid installation on all nodes.


    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan
Re: Connecting Remote machines using perl.
by salva (Canon) on Dec 19, 2005 at 09:54 UTC
    you can open a shell on the remote machine through ssh and pipe commands to it...
    open RSH, "| ssh foo\@bar /bin/sh >out.log 2>err.log" or die "ssh command failed"; select RSH; $|=1; print RSH "ls\n";
    or just write a script to install Net::SSH and copy and run it in all the machines, it should be really easy!
Re: Connecting Remote machines using perl.
by marto (Cardinal) on Dec 19, 2005 at 09:29 UTC
    Hi murugu,


    Net::SSH is not listed in the core modules list.
    You may want to check out the PAR module and pp for creating an executable containing all your dependencies.

    Hope this helps.

    Martin
Re: Connecting Remote machines using perl.
by Perl Mouse (Chaplain) on Dec 19, 2005 at 10:50 UTC
    This script will be run on any one of the 1000 clusters which are all load balanced. Iam unable to use the module Net::SSH module, why because installing the module in 1000 machines will be tedious job.
    Really? I'd say that installing a single module on 1000 machines would be a tiny task compared to installing the OS and the main applications on 1000 machines.

    You're running 1000 clusters on 1000 machines, and rolling out software among them isn't already a solved problem in your company?

    Perl --((8:>*


      I use a 128 node cluster, and the environment is fixed. Each cluster has its own local disk space accessible in /tmp/ and various places, plus a network share where you put your code. What you should be doing is putting your module in the network share. If you don't have one, you must have a very painful clustering setup to work with!

      On my system (SunFire/Linux) if the labstaff updates the build environment it propagates to all the nodes. Also, jobs have to be submitted by a load balancing queuer anyway. You can't get persistent storage on any _specific_ node, because you are assigned whatever nodes are free by the queuer.

      If you are under the impression that perl modules have to be installed in /usr/local/lib/..., and that isn't synchronized across your systems (possible, but unlucky!), you are wrong; you can install a module anywhere. Just update your lib path with a little use lib qw(/path/to/your/module); at the beginning of your perl program. You don't even have to change environment variables.

      If none of these seem like options, then you should probably ask your cluster administrator what you should do.

      Conversely you could pipe commands to `ssh` with open() or system() or something, but that's less than ideal.

      ~e
Re: Connecting Remote machines using perl.
by CountOrlok (Friar) on Dec 19, 2005 at 15:33 UTC
    I haven't used clusters but I would think an essential part of a cluster would be a control panel that lets each and every node be configured from one place, which could in turn download and install Net::SSH on to all nodes.

    -imran