1
0
mirror of https://github.com/danog/process.git synced 2024-11-26 20:24:43 +01:00
process/examples/write-command.php
Aaron Piotrowski 91dc2ec100
Update examples
2018-10-15 09:55:15 -05:00

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";
});