Cookbook /
RunCGI
Summary: Run a CGI script from a recipe illustration
Version: 2012-09-08
Prerequisites:
Status: As is
Maintainer: PmWiki community
Categories: PmWiki developer
Discussion: RunCGI-Talk
How do I invoke a CGI script from a PmWiki recipe?
Try this, in the example the script being executed is tuesday.pl
.
<?php if (!defined('PmWiki')) exit(); # # This recipe illustrates calling a CGI program from a PmWiki recipe. # Version date $RecipeInfo['RunCGI']['Version'] = '2012-09-08'; $FmtPV['$RunCGI'] = $RecipeInfo['RunCGI']['Version']; // return version as a custom page variable # 2012-09-05 Initial version # declare $RunCGI for (:if enabled RunCGI:) recipe installation check global $RunCGI; $RunCGI = 1; /* Copyright 2012 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ Markup('RunCGI', 'fulltext', '/\\(:runcgi:\\)/ei', "Keep(RunCGI())"); function RunCGI() { $retval = 'retval is '; $lastline = ''; $output = ''; $lastline = exec("../cgi-bin/tuesday.pl", $output); // return result of executing file $retval .= ' exec:' . pre_r($output); $retval .= ' fgc:' . pre_r(file_get_contents('../cgi-bin/tuesday.pl')); // return contents of file return $retval; }
Description
Enter your recipe's description here.
Installation
- save the above example as
MyRecipe.php
in the/pmwiki/cookbook/
directory - add
include_once("
to$FarmD
/cookbook/MyRecipe.php");config.php
- add
(:runcgi:)
to a wiki page
Configuration
Usage
Notes
See PHP's
See from PmWiki
pre_r
is defined inpmwiki.php
asfunction pre_r(&$x) { return '<pre>'.PHSC(print_r($x, true)).'</pre>'; }
- Markup
- Keep
See also
- PmWikiDeveloper Information for PmWiki and recipe developers
- PmWikiInternals Documentation of PmWiki Internal functions and operation
- Functions Brief description of some of PmWiki's internal functions available to cookbook recipe authors and custom markup developers
- FunctionList A simple list of the functions provided by PmWiki
- Functions How some of the functions in pmwiki.php work
Change log / Release notes
See also
Contributors
- simon September 07, 2012, at 11:50 PM
Comments
See discussion at RunCGI-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.