Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Created February 10, 2014 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhishekGhosh/8911608 to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/8911608 to your computer and use it in GitHub Desktop.
popen php
<?php
require_once(__DIR__.'/../libs/Render.php');
error_reporting(E_ALL);
//Initialize and Run Command, with a little trick to avoid certain issues
$target='cd ../../your/relative/path && ./CustomScript.sh';
$outbuf=exec($target,$stdoutbuf, $returnbuf);
//Structure
$htm= new renderable('html');
$html->children[]= $head= new renderable('head');
$html->children[]= $body= new renderable('body');
$body->children[]= $out= new renderable('div');
$body->children[]= $stdout= new renderable('div');
$body->children[]= $returnout= new renderable('div');
//Value
$out->content= 'OUTPUT: '.$outbuf;
$stdout->content= 'STDOUT: '.var_export($stdoutbuf,true);
$returnout->content= 'RETURN: '.$returnbuf; //127 == Pathing problem
//Output
print_r($html->render());
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment