[ale] simple PHP question on proc_open

Jerry Yu jjj863 at gmail.com
Mon Feb 12 20:57:52 EST 2007


Thanks, Jay.  Once I changed it from 'file' to 'pipe', it runs w/o problem.
Now to think of it, the error is somewhat troubling, since $descriptors
array actually changed to command to be executed?!
The wordpress plugin was an old one. So, the 'file' type obviously was ok
for PHP 4.3 (CentOS 4.4), but is not ok for PHP 5 (FC6)

On 2/12/07, Jay Loden <jloden at toughguy.net> wrote:
>
> On PHP 5.1.2 which is what I'm running, I think the problem is you need to
> specify a type of "pipe" and not file for the php://stderr like so:
>
> <?php
>
> $cmd = 'date';
>
> $descriptors = array(
>          0 => array("pipe", "r"),
>          1 => array("pipe", "w"),
>          2 => array("pipe", "php://stderr", "w")
>    );
> $process = proc_open('/bin/date', $descriptors, $fd_set);
> if (is_resource($process)) {
>         print "got it: " . stream_get_contents($fd_set[1]);
> }  else { print "NO NO"; }
>         proc_close ($process);
> ?>
>
> The above executed fine on my system, running it from the command line. I
> believe if you run this from a webserver you'll need to specify the full
> path of /bin/date since the PATH env variable won't be passed the same if
> it's running as the apache user.
>
> -Jay
>
> Jerry Yu wrote:
> > Thanks, Jay. I tried with 'cwd' passed in. same error, still.
> > Here is the exact error I am getting:
> > $ php j.php
> > PHP Warning:  proc_open(): cannot seek on a pipe in /tmp/j.php on line
> 11
> > sh: /date: No such file or directory
> > got it
> >
> > Same script, j.php runs w/o problem with PHP/4.3 on CentOS 4.
> >
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list