doutu1939 2015-03-03 23:09
浏览 10

PHP中外部程序的实时输出

I've written and compiled a command line program (abc.exe) that runs for about 10 mins, makes some calculations and outputs 1 line of results per 10 secs, like this:

C:\>abc.exe
Result 1
Result 2
Result 3
.
.
.

The following php script should theoretically show these results in real time, as they are produced by the program.

<?php 
$a = popen('abc.exe', 'r');
while($b = fgets($a)) { 
echo $b."<br>
"; 
ob_flush();flush(); 
} 
pclose($a); 
?>

However, I just get all the results at the end of the execution of the program. Why could this be happening?
Please note that if I replace abc.exe with ping 8.8.8.8 or tracert 8.8.8.8, the script works like a charm. Please, help me, I've tried everything that is suggested in similar questions here, but nothing seems to work!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stm32代码移植没反应
    • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
    • ¥100 连续两帧图像高速减法
    • ¥15 组策略中的计算机配置策略无法下发
    • ¥15 如何绘制动力学系统的相图
    • ¥15 对接wps接口实现获取元数据
    • ¥20 给自己本科IT专业毕业的妹m找个实习工作
    • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
    • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
    • ¥50 mac mini外接显示器 画质字体模糊