Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Calling a perl script and passing parameters from html

by Jenda (Abbot)
on Nov 17, 2012 at 17:26 UTC ( #1004326=note: print w/replies, xml ) Need Help??

in reply to Calling a perl script and passing parameters from html

If the script doesn't take too long to execute and you do not need to process it's results then a wrapper script like this should be enough to get you up and running:

use strict; use CGI; use CGI; my $q = new CGI; @ARGV = (); foreach ($q->param()) { $value = $q->param($_); $value =~ s/"/\\"/g; push @ARGV, "--" . $_ . '="' . $value . '"'; } do 'path/to/the/';

All it does is it moves the parameters from the querystring or post into the @ARGV array (array of script parameters) in the format required by the script and then executes the script without starting a new process.

As long as the script prints its results to STDOUT they should be sent to the client browser.

Enoch was right!
Enjoy the last years of Rome.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004326]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2018-05-25 17:11 GMT
Find Nodes?
    Voting Booth?