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

20 lines
410 B
PHP
Raw Normal View History

<?php
include dirname(__DIR__) . "/vendor/autoload.php";
2017-06-15 19:02:50 +02:00
use Amp\ByteStream\Message;
2017-01-15 16:30:34 +01:00
use Amp\Process\StreamedProcess;
2017-06-15 19:11:38 +02:00
Amp\Loop::run(function () {
$process = new StreamedProcess('read ; echo "$REPLY"');
2017-06-15 19:02:50 +02:00
$process->start();
/* send to stdin */
$process->write("abc\n");
2017-06-15 19:02:50 +02:00
echo yield new Message($process);
2017-06-15 19:02:50 +02:00
$code = yield $process->join();
2017-01-15 16:30:34 +01:00
echo "Process exited with {$code}.\n";
});