exe不给输出在PHP [英] exe not giving output in php
问题描述
我正在尝试从php调用exe.该exe是从Qt创建的.它在Qt以及从命令行运行,但是当我尝试从php运行它时,我得到的输出不完整.该exe需要大约5到7秒的时间才能运行.
I am trying to call an exe from php. the exe is created from Qt. It runs in Qt as well as from the command line but when I try to run it from php I get incomplete output. The exe takes around 5-7sec to run.
我从命令行获得的输出是:
The output that I get from command line is:
--(!)Error loading
--(!)Error loading
1
2
3
4
5
我不确定加载错误的目的是什么,但是它仍然运行exe并给出输出.但是当我从php运行它时,我得到了
I am not sure what the error loading is for but it stills run the exe and gives the output. But when I run it from php I get
array(2) { [0]=> string(18) "--(!)Error loading" [1]=> string(18) "--(!)Error loading" }
错误加载后,在命令行中花费一些时间才能给出输出,因此php可能不会等待它完成.我不知道.如何找出错误所在,以及如何解决?我用来调用exe的php脚本是:
After Error loading it takes abit time in the command line to give the output so may be the php does not wait for it to complete. I am not sure. How can I find out what the error is and how can I solve this? The php script that I am using to call the exe is:
<?php
$addr="/home/ggt/project/build-test-Desktop-Release/test";
exec($addr,$data);
var_dump($data);
?>
我也尝试过使用shell_script.但这是行不通的.我什至在exec之后插入了sleep(20),但还是一样.
I tried using shell_script too. But it does not work. I even inserted a sleep(20) after exec but still its the same.
推荐答案
我解决了这个问题...这是因为代码中有一个imshow(),我没有对此发表评论.因此,它没有执行整个程序并停止了它.删除imshow之后,我就能获得所有输出.
I solved the problem...It was because there was an imshow() in the code which I missed to comment out. So, it did not execute the whole program and stopped it. After I removed the imshow I was able to get all the output.
这篇关于exe不给输出在PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!