By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

proc_open, write error to var instead file??

P: n/a
Howdy,

For a script I need the exact output of the apache htdbm.exe to a var so
I can extract all users from a database. Now I found out that this can
be done with Proc_open. I got this script from the php website which
looks something like copied below...

Since I can not find very good documentation on this function my
question is: I suppose that the problem is with this
2 => array("file", "error-output.txt", "w") // stderr is a file to

How do I need to edit this to make the 'error' be written in a var
instead of a file..? I tried a few thing but did not succeed.

Thanks in advance, Maarten
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read
from
1 => array("pipe", "w"), // stdout is a pipe that the child will
write to
2 => array("file", "error-output.txt", "w") // stderr is a file to
write to
);
$process = proc_open("E:\\passwords\\htdbm.exe -l
$password_dir\\.htpasswd", $descriptorspec, $pipes);
if (is_resource($process)) {
// $pipes now looks like this:
// 0 => writeable handle connected to child stdin
// 1 => readable handle connected to child stdout
// Any error output will be appended to /tmp/error-output.txt

fwrite($pipes[0], "");
fclose($pipes[0]);

while(!feof($pipes[1])) {
echo fgets($pipes[1], 1024);
}
fclose($pipes[1]);
// It is important that you close any pipes before calling
// proc_close in order to avoid a deadlock
$return_value = proc_close($process);
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.