The solution here depends on how much work you want to do and what permissions you have on Machine B. If you can SSH to it then Net::OpenSSH to execute commands is the simplest and quickest way to get this done. Other options will require you to put some code on Machine B.
One easy to implement but heavier(in terms of system resources) option is to run a webservice on a unoccupied port number using Dancer or Catalyst etc. on Machine B and let the webservice run the commands and return the result to you.
Third option albeit insecure in its bare form is to write a program using one of the event handling systems like AnyEvent, EV or POE to create a listening network socket on Machine B. This requires familiarity with event loops.
Make a socket connection from Machine A to Machine B when required and send the command to run. The Target Machine can then process the command and stream the result back to the Machine A on the same socket.
You can use POE::Component::Server::TCP on Machine B and POE::Component::Client::TCP on Machine A.
Note that on Machine B the server must run with the same permissions that you wish to grant for running the commands(You dont want a random person running "sudo rm -rf /"). Of course a better assurance against abuse would be to write some code in the server to decide weather to accept a command or not.
In reply to Re: How to execute Perl code on remote machine from a local Perl script and process the output/variables in your local Perl script
by shantanu_bhadoria
in thread How to execute Perl code on remote machine from a local Perl script and process the output/variables in your local Perl script
by dushyant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |