Last active
December 18, 2016 09:30
-
-
Save harmo/14a3553eb2a1ec4751ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public static function my_exec($cmd, $input = '', $outputFile = ''){ | |
$proc = proc_open($cmd, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('file', $outputFile, 'w')), $pipes); | |
fwrite($pipes[0], $input); | |
fclose($pipes[0]); | |
$stdout = stream_get_contents($pipes[1]);fclose($pipes[1]); | |
$rtn = proc_close($proc); | |
return array( | |
'stdout'=>$stdout, | |
'return'=>$rtn | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment