Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Remotely Start/Stop Services

by perl514 (Pilgrim)
on Feb 02, 2013 at 01:28 UTC ( #1016631=note: print w/replies, xml ) Need Help??

in reply to Remotely Start/Stop Services



You can have your script read a text file that has the server names given one below the other. Then, your script would read each line of the text file, pick up the servername, do a ping or an nslookup and if thats successful, it would execute the command. To remotely execute the commands, try the Net::SSH2 Module or Net::SSH::Any module.

Net::SSH2 comes pre installed with Strawberry Perl or DWIM Perl. Net::SSH::Any you'll have to install and it will run on top of Net::SSH2. Hope this helps.

Perlpetually Indebted To PerlMonks

use Learning::Perl; use Beginning::Perl::Ovid; print "Awesome Books"; is a boon for Windows.

Replies are listed 'Best First'.
Re^2: Remotely Start/Stop Services
by dasgar (Curate) on Feb 02, 2013 at 05:54 UTC

    The modules that you suggested would work great if the remote systems were Linux. But it looks like the OP in a Windows only environment. Windows doesn't come with an SSH server. Although someone could install something like openSSH or Cygwin to get an SSH server running on Windows, I'm not entirely sure that the SSH environment in that case would have to utilities to control Windows services. I personally have never tried that so I guess I could be wrong about that.

    Anyways, IMHO I still think it will be much quicker and easier to use PsService or PsExec from the SysInternals suite.

      Hi dasgar,


      I have tried these modules on Windows and they work fine.

      If the OP wants to login to servers, he will have to have ssh installed on the Win Workstation from which he will be firing his queries. That is why I suggested the options.

      Perlpetually Indebted To PerlMonks

      use Learning::Perl; use Beginning::Perl::Ovid; print "Awesome Books"; is a boon for Windows.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016631]
choroba waves
[Mj1234]: Hello Monks, I have installed Active perl 5.16 and 5.14 but I dont find Devel::GDB package when I try to install through ppm
[Discipulus]: i'v installed ubuntu 16.04lts and i'm quite disappointed: is deadly simmilar to new win osses where you cannot find even simple things...
[Corion]: Hi Discipulus ;)
[Corion]: Mj1234: Maybe Ubuntu didn't package Devel::GDB? In that case, consider using local::lib and install the module from CPAN
[Corion]: But a quick Google search turns up this page, which seems to suggest that it should be packaged
[Discipulus]: iirc active perl has repositories only for last 2 o 3 major release of perl Mj1234. I strongly suggest portable version of strawberry perl and use cpan client to install modules
[choroba]: Also, who needs GDB when there's hdb?

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2016-12-07 08:51 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (125 votes). Check out past polls.