1
0
mirror of https://github.com/danog/process.git synced 2024-12-02 09:37:55 +01:00
process/examples/write-command.php
2017-06-15 12:52:07 -05:00

20 lines
419 B
PHP

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