たとえば、次のコマンドを見てみましょう。
$command = "echo '/just/for/the/test /heh/' | awk '//just// {print $1}'";
シェル内で直接コピーすると、次のエラーが発生します。
awk: cmd. line:1: //just// {print $1}
awk: cmd. line:1: ^ unterminated regexp
しかし、私exec()
がそれをすると、出力なしでステータスコード 1 を取得します。
exec($command, $output, $status);
var_dump( $command, $output, $status );
// string(69) "echo '/just/for/the/test /heh/' | awk '//just// {print $1}'"
// array(0) { }
// int(1)
exec の STDERR 部分を取得するには?