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

Hello Mates

i have shell script file which launches some processes on Distributed Servers.
I need To Execute Shell Script using any perl Script .

I have the Server ip details and the Script location in that Server with me. PerlScript Should Excute that.sh file on that Server in that location.

Please Help.
Thanks in advance.
Koti.
  • Comment on How to Run a shell script which is on a remote server using a Perl script

Replies are listed 'Best First'.
Re: How to Run a shell script which is on a remote server using a Perl script
by mikeraz (Friar) on May 07, 2009 at 12:52 UTC

    Why use Perl?

    $ for S in `cat file_of_target_addrs` > do > ssh $S '/path/to/command/to/that.sh' > done $ (assuming your shell supports for loops, sub with local syntax as need +ed)
    What in your problem space requires Perl?


    Be Appropriate && Follow Your Curiosity
      Why use cat? Kill the cat!
      $ while read S > do > ssh $S '/path/to/command/to/that.sh' > done < file_of_target_addrs
Re: How to Run a shell script which is on a remote server using a Perl script
by gemoroy (Beadle) on May 07, 2009 at 12:50 UTC
    use any RPC proto that you like(you can use system(); to execute shell comand)..or write a tcp server(http://perldoc.perl.org/IO/Socket.html) on that machine that accept's a path to script and then
    my $cmd = "sh /my/script/myscript.sh"; system $cmd;
Re: How to Run a shell script which is on a remote server using a Perl script
by TGI (Parson) on May 07, 2009 at 17:43 UTC

    I am not sure I understand your question.

    Here's what I read:

    1. You have a shell script that will start processes on multiple servers.

    2. You need to execute a shell script using perl

    3. You have server IP and script path information.

    4. You want your perl script to start the scripts running on the servers specified in 3.

    Why can't you use the shell script you describe in 1? If you need to run it from perl, use the system command or backticks (``).


    TGI says moo

Re: How to Run a shell script which is on a remote server using a Perl script
by VinsWorldcom (Prior) on May 07, 2009 at 12:49 UTC

    Perhaps I'm missing the point, but there already is an application to do what you want. It's called Telnet. Telnet to the server and start the shell script.

    If your solution *MUST* be in Perl, have a look at Net::Telnet.

A reply falls below the community's threshold of quality. You may see it by logging in.