PHP Classes


Recommend this page to a friend!
  Classes of Payam Naderi   PHP Execute Shell Command   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Execute Shell Command
Execute system command piping input and output
Author: By
Last change:
Date: 4 years ago
Size: 782 bytes


Class file image Download


Execute system commands.


// Execute Command Line:
$exec = new ExeProc();
$re = $exec->exec("md5sum");

// Open Http Socket Connection:
$tcpClient = new \Poirot\Stream\WrapperClient('', 'r');
$stream = new \Poirot\Stream\Streamable($tcpClient->getConnect());
# pipe all http data as input for command(md5sum)
# close write input data

// Read Output result, as stream:
$md5 = $re->pipes()->stdout()->readLine();

if ($re->pipes()->to(iExecDescriptor::XCDSC_STDERR) !== '') {
    // get stderr messages
    // ...

// Close Process:

var_dump($md5); // md5 hash of website content: fa59c70d613d4d0085b4d869c46288c9