Re: [pmwiki-devel] Calling CGI from PHP
Simon writes: 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 URL:http://ttc.org.nz/pmwiki/pmwiki.php/TTC/Tuesdaya page. 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('URL:http://ttc.org.nz/cgi- bin/tuesday.plhttp://ttc.org.nz/cgi-bin/tuesday.pl', false, $context); This should work unless some restrictions are set on that PHP installation. You may also try simply file_get_contents('http://ttc.org.nz/cgi-bin/tuesday.pl'); $lastline = system ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output); This would probably never work. You normally cannot execute remote files. $retval .= 'b' . $output; $lastline = exec ('http://ttc.org.nz/cgi-bin/tuesday.pl', $output); $retval .= 'c' . $output; Same here. $lastline = exec(./cgi-bin/tuesday.pl, $output); This will likely be ../cgi-bin/tuesday.pl with 2 dots, because it looks like your running pmwiki.php file is in a directory pmwiki, while the cgi- bin directory looks like it is in the document root, and not inside the pmwiki directory. return $retval; For testing purposes, in order to see the array values rather than 'Array', try return pre_r($retval); Petko ___ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel
Re: [pmwiki-devel] Calling CGI from PHP
A big thanks to Petko and Peter B who got me heading in the right direction. I've documented this at http://www.pmwiki.org/wiki/Cookbook/RunCGI I hope it helps someone else Simon On 7 September 2012 19:48, Petko Yotov 5...@5ko.fr wrote: Petko Yotov writes: $retval .= 'c' . $output; For testing purposes, in order to see the array values rather than 'Array', try return pre_r($retval); This was incorrect, sorry. You can use the pre_r() function on all $output variables above, not on $retval: $retval .= 'c' . pre_r($output); Petko __**_ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/**mailman/listinfo/pmwiki-develhttp://www.pmichaud.com/mailman/listinfo/pmwiki-devel -- http://kiwiwiki.co.nz ___ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel
[pmwiki-devel] Calling CGI from PHP
I've got a legacy html page http://ttc.org.nz/tuesday.html which calls a cgi (perl) script !--#include virtual=/cgi-bin/tuesday.plhttp://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 pagehttp://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 pagehttp://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 ___ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel