I am running the following proc_open
function. When the page is loaded, I get the error:
Use of undefined constant STDOUT - assumed 'STDOUT'`
How should I set STDOUT
and STSDERR
correctly?
PHP Snippet
$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);
?>
When I chmod 755 test.php
and run ./test.php
in the command line (CentOS), I get the error output:
: 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(
This is puzzling, =
is not a command?
#!/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);
?>
I get the output:
Status: 404 Not Found
X-Powered-By: PHP/5.3.16
Content-type: text/html
No input file specified.
You may use :
$descriptorspec = array(
0 => array('pipe', 'r'), // stdin
1 => array('pipe', 'w'), // stdout
2 => array('pipe', 'a') // stderr
);
instead
Have a look to the manual