1
0
mirror of https://github.com/danog/process.git synced 2025-01-22 05:41:17 +01:00
process/example/write-command.php
2017-01-15 09:30:34 -06:00

19 lines
410 B
PHP

<?php
include dirname(__DIR__) . "/vendor/autoload.php";
use Amp\Process\StreamedProcess;
AsyncInterop\Loop::execute(\Amp\wrap(function() {
$process = new StreamedProcess('read ; echo "$REPLY"');
$promise = $process->execute();
/* send to stdin */
$process->write("abc\n");
echo yield $process->getStdout();
$code = yield $promise;
echo "Process exited with {$code}.\n";
}));