Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Perl script on selected host via CGI 1

Status
Not open for further replies.

blarneyme

MIS
Jun 22, 2009
160
US
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.

Kirsle.net | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top