I am trying to excecute a perl script from a php script and use the returned html. I'm having no success. The script can successfully be called from a .shtml file. I have read this forum (and others for that matter) pretty comprehensively to no avail (alas!).
I have an old .shtml file that is calling the perl script using ssi thusly:
<!--#exec cmd='./personalized.cgi'-->
which looks (about) like this:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use DBI;
use iDB;
$debug = 1;
$client_cookie = cookie('mydom');
$seeker_cookie = cookie('mydom_jobseeker');
if ($client_cookie) {
&known_client;
} elsif ($seeker_cookie) {
&known_seeker;
} else {
&unknown;
}
sub known_seeker {
&DBConnect(my_db);
$sql = "SELECT first_name,last_name FROM seekers WHERE id = $seeker_cookie";
$sth = $dbh->prepare($sql) || die "Can't prepare statement: $DBI::errstr";
$sth->execute() || die $sth->errstr;
($first_name,$last_name) = $sth->fetchrow_array;
print "<strong>Welcome back $first_name</strong>";
}
sub known_client {
&DBConnect(my_db);
$sql = "SELECT name,contact FROM clients WHERE id = $client_cookie";
$sth = $dbh->prepare($sql) || die "Can't prepare statement: $DBI::errstr";
$sth->execute() || die $sth->errstr;
($name,$contact) = $sth->fetchrow_array;
print "<p><strong>Welcome back $contact</strong>.</p>";
}
sub unknown {
print "hey";
}
I am doing the site in php but really don't have the time to redo all the crazy scripting that has been layed down for the site.
I am trying many things in php to execute and dump the html product back into the page, but to no avail.
The closest I've come so far is to use:
exec ("personalized.cgi",$output);
echo $output; //just for the hell of it (returns "Array")
echo count($output); // also for the hell of it (returns "0"..also know as a bloody gooseegg :-p)
while ($x<count($output)) {
echo 'hey<br>';
echo $output[$x].$x.": <br>";
$x++;
}
Which tells me I have an empty array.
Please help! Thank you!