I have a third party Perl script designed to be executed by a browser and which processes data in a HTTP POST request.
The script can be executed from the command line but when doing so it is not being executed in the expected environment and as such does not have access to required user data.
I need to execute the script very frequently and want to avoid the overhead of spinning up an Apache process to handle what can instead be handled at the command line. The script executes from the command line much much much faster than via Apache (at least with no input data).
I'd like to wrap up the script such that command line arguments are passed to the script as if they were present in a HTTP POST request.
I'm not very familiar with Perl and would like to present a (rudimentary) example in PHP to represent what I intend to achieve.
<?php
$_POST['example1'] = $argv[1];
$_POST['example2'] = $argv[2];
include /var/www/thirdPartyScript.php
?>
The Perl script accesses data as follows:
#!/usr/bin/perl -T
use CGI 3.40 qw(-newstyle_urls -private_tempfiles redirect);
# ...
my $q = CGI->new();
# ...
if ($q->param('example1') {
} else {
}
What would the wrapper script need to set such that the third party script has access to relevant data as if that data were provided in a HTTP POST request?