<?xml version="1.0" encoding="windows-1252"?>
<node id="1004326" title="Re: Calling a perl script and passing parameters from html" created="2012-11-17 12:26:59" updated="2012-11-17 12:26:59">
<type id="11">
note</type>
<author id="105128">
Jenda</author>
<data>
<field name="doctext">
&lt;p&gt;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:&lt;/p&gt;

&lt;code&gt;
use strict;
use CGI;
use CGI;
my $q = new CGI;
@ARGV = ();
foreach ($q-&gt;param()) {
	$value = $q-&gt;param($_);
	$value =~ s/"/\\"/g;
	push @ARGV, "--" . $_ . '="' . $value . '"';
}

do 'path/to/the/script.pl';
&lt;/code&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;As long as the script prints its results to STDOUT they should be sent to the client browser.&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-105128"&gt;
&lt;p&gt;Jenda&lt;br&gt;
&lt;b&gt;Enoch was right!&lt;/b&gt;&lt;br/&gt;
Enjoy the last years of Rome.
&lt;/p&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1004247</field>
<field name="parent_node">
1004247</field>
</data>
</node>
