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

19 lines
410 B
PHP
Raw Normal View History

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