mirror of
https://github.com/danog/process.git
synced 2024-11-26 20:24:43 +01:00
25 lines
551 B
PHP
25 lines
551 B
PHP
<?php
|
|
|
|
include \dirname(__DIR__) . "/vendor/autoload.php";
|
|
|
|
use Amp\ByteStream;
|
|
use Amp\Process\Process;
|
|
|
|
Amp\Loop::run(function () {
|
|
if (DIRECTORY_SEPARATOR === "\\") {
|
|
echo "This example doesn't work on Windows." . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
$process = new Process('read; echo "$REPLY"');
|
|
yield $process->start();
|
|
|
|
/* send to stdin */
|
|
$process->getStdin()->write("abc\n");
|
|
|
|
echo yield ByteStream\buffer($process->getStdout());
|
|
|
|
$code = yield $process->join();
|
|
echo "Process exited with {$code}.\n";
|
|
});
|