[pmwiki-devel] Calling CGI from PHP

Simon nzskiwi at gmail.com
Thu Sep 6 03:09:11 CDT 2012


I've got a legacy html page <http://ttc.org.nz/tuesday.html> which calls a
cgi (perl) script <!--#include
virtual="/cgi-bin/tuesday.pl<http://ttc.org.nz//cgi-bin/tuesday.pl>"
-->

As an interim step to replacing this script (with something clever from
PmWiki) I've tried to invoke the script from within a recipe on a
page<http://ttc.org.nz/pmwiki/pmwiki.php/TTC/Tuesday>
.

The recipe is
Markup('ClubNight', 'fulltext', '/\\(:clubnight:\\)/ei',
  "Keep(ClubNight())");
function ClubNight() {
  $retval = 'retval is ';
  $lastline = '';
  $output = '';
  // Create a stream
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n"
  )
);
  $context = stream_context_create($opts);
// Open the file using the HTTP headers set above
  $retval .= 'a' . file_get_contents('http://ttc.org.nz/cgi-bin/tuesday.pl',
false, $context);
  $lastline = system ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output);
  $retval .= 'b' . $output;
  $lastline = exec ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output);
  $retval .= 'c' . $output;
  $lastline = exec("./cgi-bin/tuesday.pl", $output);
  $retval .= 'd' . $output;

  return $retval;
}

I don't get the result I expect on the
page<http://ttc.org.nz/pmwiki/pmwiki.php/TTC/Tuesday>
,
and wonder if anyone can spot anything obvious that I have got wrong.
I'm sure safe mode is on.

tia

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-devel/attachments/20120906/e517a1a1/attachment.html>


More information about the pmwiki-devel mailing list