27 lines
512 B
PHP
27 lines
512 B
PHP
<?php
|
|
|
|
use Nih\CommandBuilder\Command;
|
|
use Nih\CommandBuilder\Stdio;
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
$output = (new Command('echo'))
|
|
->arg('-n')
|
|
->arg('-')
|
|
->arg("./ \$wow '''/stdout.txt")
|
|
->stderr(Stdio::null())
|
|
->output();
|
|
|
|
var_dump($output);
|
|
|
|
$child = (new Command('/usr/bin/cat'))
|
|
->stdin(Stdio::piped('r'))
|
|
->spawn(shell: true);
|
|
|
|
$child->stdin?->write('Hello, this is pretty cool.');
|
|
$child->stdin?->close();
|
|
|
|
$output = $child->output();
|
|
|
|
var_dump($output);
|