如何在运行时执行shell命令并在网页上显示内容?

I am trying to start a cd rip with cdparanoia -E 1 and want to process the progress bar.

The sample code does output content in browser but just after everything is finished. If its called in cli content is displayed directly.

$cmd = 'cdparanoia -e 1';

@ob_end_clean();

$proc = popen($cmd, 'r');
while (!feof($proc))
{
    echo fread($proc, 4096).'<br>';
    flush();
    @ob_flush();
}

My env is debian with nginx 1.6.2 and php5-fpm 5.6.17.