On a web page I have a list of 20 servers and one is selected from a drop down list for example. How do I execute a Perl script to run on the selected host?
The easiest way is to make a CGI front-end that launches the script that your script can call remotely.
i.e.
Code:
use LWP::Simple; # simple URL retrieving
# run startscript.cgi on the other server
get "[URL unfurl="true"]http://$server/cgi-bin/startscript.cgi";[/URL]
and startscript.cgi would run the perl script you want on that server via a system() command (assuming the cgi script, itself, is not the script you really want to run).
You can secure it a bit by putting the CGI front-end inside a password-protected directory that requires a username and password to access it over the web, and use LWP::UserAgent to provide that info (LWP::Simple isn't advanced enough). See
More complicated ways would involve setting up an RPC daemon or using SSH or VPN tunnels... but these are largely outside the scope of Perl and would be better asked on other forums.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.