I am running on windows XP with a fresh install of wamp5 (1.7.2) and mediawiki.
I am trying to call a perl function from within php using proc_open.
The perl script is being executed and returns a successful exit value, and I can read the results it prints to STDOUT in PHP, but the perl script does not see STDIN from PHP. Since I want to use the perl script as a filter and I don't want to create an intermediary file, this is problematic.
Any advice? Could it be some sort of permissions thing?
Here is the PHP:
[PHP]
$descriptorspec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'r')
);
$pipes = array();
$resource = proc_open($comm and, $descriptorspec , $pipes);
if (!is_resource($ resource)) {
$fail = "Unable to launch process";
} else {
$stdin = $pipes[0];
$stdout = $pipes[1];
$stderr = $pipes[2];
fwrite($stdin, "this\nis\na\nt est\n");
fclose($stdin);
while (!feof($stdout) ) {
$ouput .= fgets($stdout);
}
while (!feof($stderr) ) {
$error .= fgets($stderr);
}
fclose($stdout) ;
fclose($stderr) ;
$exit_code = proc_close($res ource)
[/PHP]
And here is the simple perl script:
All I see from the perl script in $stdout is"Test"....
Grateful for any help!
I am trying to call a perl function from within php using proc_open.
The perl script is being executed and returns a successful exit value, and I can read the results it prints to STDOUT in PHP, but the perl script does not see STDIN from PHP. Since I want to use the perl script as a filter and I don't want to create an intermediary file, this is problematic.
Any advice? Could it be some sort of permissions thing?
Here is the PHP:
[PHP]
$descriptorspec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'r')
);
$pipes = array();
$resource = proc_open($comm and, $descriptorspec , $pipes);
if (!is_resource($ resource)) {
$fail = "Unable to launch process";
} else {
$stdin = $pipes[0];
$stdout = $pipes[1];
$stderr = $pipes[2];
fwrite($stdin, "this\nis\na\nt est\n");
fclose($stdin);
while (!feof($stdout) ) {
$ouput .= fgets($stdout);
}
while (!feof($stderr) ) {
$error .= fgets($stderr);
}
fclose($stdout) ;
fclose($stderr) ;
$exit_code = proc_close($res ource)
[/PHP]
And here is the simple perl script:
Code:
#!/usr/bin/perl
use strict;
use warnings;
my $output;
while (<STDIN>) {
$output = "FOO: $_\n";
}
print STDOUT "Test\n";
print STDOUT $output;
exit 0;
All I see from the perl script in $stdout is"Test"....
Grateful for any help!
Comment