Page 2 of 2

Try this.

Posted: Sun Mar 16, 2003 8:23 am
by Ron Woolley
:arrow: "Grabs" the output in to an array for munging. Other methods just display out put lock stock and barrel; http header and all.

This will work with any cgi that does not need queries sent to it - i.e. rotating banner adds too... whatever, all perl output is collected. Ideal for the many existing better perl SSIs around (php has its uses, so does Perl).

----------------------------------
<head>
<title> ** SSI to PHP attempt ** </title>
</head>
<body>

<p>G'Day! Here's the output:<br><hr>
<?php
// you cannot send query strings via php - stupid.

// use absolute paths
$cmndPATH = ''; // associated through $progPATH, so blank for Perl calls
if($cmndPATH > ''){$cmndPATH . " ";}
$progPATH = '/www/domain/cgi-bin/perl.cgi';
$call = $cmndPATH . $progPATH;
$rslt='';$e='';

// $e > 0 = error trap
exec ( escapeshellcmd($call), $rslt, $e );

// array to managable multi line string - i.e. similar to Perl "join'
$rslt = implode( "\n", $rslt );

if($e){$rslt = "Ooops! Error: $e";}

// remove returned header (look for first multi break) - how/what depends on source program; usually ok as is (\n Unix)..
$rslt = preg_replace ('/^.+\n{2,}/', '', $rslt);
// else you might have to loop through array before 'implode'

// do it
echo "$rslt";
?>
<hr>
</body>
</html>

-----------------------------------------
See working at http://www.dtp-aus.com/etest/SSI.php