Skip to content
Advertisement

Trying in PHP to mysqldump -v to popen and not getting output

I’m writing a wrapper for mysqldump and want to show the output nicely in a PHP CLI application.

I’m attempting to run mysqldump -v using popen so that I can get the verbose output and display progress indicators to the user. However no output is returned (by default it gets logged to the screen via stdErr).

I tried adding 2>&1 to the command to push the verbose output from stdErr to stdOut, but fread still doesn’t get any output even though the output nolonger goes to the screen via stdErr.

JavaScript

Should I use something else instead of popen? Or am I simply incorrectly redirecting the output?

Advertisement

Answer

I figured it out, without having to use a file as a stream buffer.

JavaScript

I’m basically making Background class to run a terminal command and pipe the output to callback functions. It obviously still has a long way to go though.

Thanks for your help, @Victor

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement