1
0
mirror of https://github.com/danog/process.git synced 2024-12-04 10:38:04 +01:00
process/example/write-command.php

22 lines
503 B
PHP
Raw Normal View History

<?php
include dirname(__DIR__) . "/vendor/autoload.php";
use Amp\{ Listener, Process\StreamedProcess };
AsyncInterop\Loop::execute(\Amp\wrap(function() {
$process = new StreamedProcess('read ; echo "$REPLY"');
2017-01-11 21:35:07 +01:00
$process->execute();
/* send to stdin */
$process->write("abc\n");
$listener = new Listener($process->getStdOut());
while (yield $listener->advance()) {
echo $listener->getCurrent();
}
echo "Process exited with {$listener->getResult()}.\n";
}));