次のproc_open
関数を実行しています。ページが読み込まれると、次のエラーが表示されます。
Use of undefined constant STDOUT - assumed 'STDOUT'`
どのように正しく設定すればよいSTDOUT
ですSTSDERR
か?
PHP スニペット
$cmd = 'psql -p 5432 -d nominatim';
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => STDOUT, // stdout is a pipe that the child will write to
2 => STDERR // stderr is a file to write to
);
$pipes = null;
$process = proc_open($cmd, $descriptorspec, $pipes);
アップデート
<?php
$cmd = 'psql -p 5432 -d nominatim';
$descriptorspec = array(
0 => array('pipe', 'r'), // stdin
1 => array('pipe', 'w'), // stdout
2 => array('pipe', 'a') // stderr
);
$pipes = null;
$process = proc_open($cmd, $descriptorspec, $pipes);
?>
コマンドライン (CentOS) でchmod 755 test.php
実行すると、次のエラー出力が表示されます。./test.php
: No such file or directory
: command not found
./test.php: line 3: =: command not found
: command not found
: command not found
./test.php: line 5: syntax error near unexpected token `('
'/test.php: line 5: ` $descriptorspec = array(
これは不可解=
です、コマンドではありませんか?
更新 2
#!/usr/bin/php <?php
$cmd = 'psql -p 5432 -d nominatim';
$descriptorspec = array(
0 => array('pipe', 'r'), // stdin
1 => array('pipe', 'w'), // stdout
2 => array('pipe', 'a') // stderr
);
$pipes = null;
$process = proc_open($cmd, $descriptorspec, $pipes);
?>
出力が得られます:
Status: 404 Not Found
X-Powered-By: PHP/5.3.16
Content-type: text/html
No input file specified.