exec php [英] exec php

查看:80
本文介绍了exec php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好


我有一个php网站。某些页面需要调用外部程序。

程序是自制的c#应用程序。


它用于工作没有问题。一阵子。也许它适用于一些

小时。或者一天。甚至一个星期。


在某个时刻,当php脚本调用exe文件时,

应用程序会冻结。发生以下情况:


< ;?

$ return_value = exec(''path_to_exe_file'');

echo $ return_value ;

?>


嗯,exec执行了(我可以看到,exe文件执行的是什么吧

必须做)。但它不会回到php脚本。 php脚本

等待应用程序将返回,但它不会返回。在

a特定时间执行执行的时间。


如果我去命令行并执行一个exe文件(同一个

exec调用),然后它没有问题,并立即返回。

但是从exec调用它不会返回。


如何解决这个?好吧,我重新启动服务器。母鸡一切

再次运作。这意味着脚本可以再次使用exec而无需

无限等待。


当问题开始时(当exec开始失败时)服务器可以

仍然没有问题。所有脚本都运行。

不运行的唯一脚本是那些内部有exec调用的脚本。


error.log没有说明这一点。


我在Windows Server 2003上运行apache 2.X.PHP版本是5.x.

停止从c#app返回返回值。 c#app可以

也是一个简单的只有一个console.write(类似echo)。

但是当exec挂起时,这两种方法都不会起作用。 />

有人可以看到问题吗?

Hello

I have a php site. Some page needs to call an external program. The
programs are home made c# applications.

It uses to work without problem. For a while. Maybe it work for some
hour. Or for a day. Or even for a week.

At a certain point, when a php script calls the exe file, the
application freezes. The following happens:

<?
$return_value = exec(''path_to_exe_file'');
echo $return_value;
?>

Well, the exec is executed (I can see that, the exe fil does what it
has to do). But it doesnt return to the php-script. The php-script
waits infinitely that the app will return, but it will not return. At
a certain point the time execution exeedes.

If I go to the command line and execute an exe file (the same one that
exec calls), then it works without problem, and returns immediatly.
But from the exec call it doesnt return.

How do I solve this? Well, I restart the server. And hen everything
works again. Which means that the script can use exec again without
waiting infinitely.

When the problems begin (when the exec begins to fail) the server can
still work without problem. All the scripts run. The only scripts that
dont run are those that have the exec call inside.

error.log doesnt says anything about this.

Im running apache 2.X on windows server 2003. PHP version is 5.x.

I have put log function before and after every single call to exec. I
analyzed it, but I can not understand why the exec fails. It only
stops to get back the return value from the c# app. The c# app can
also be a simple one with only a console.write (something like echo).
But when exec has hanged up neither that will work.

Someone can see the problem?

推荐答案

return_value = exec(''path_to_exe_file'');

echo
return_value = exec(''path_to_exe_file'');
echo


return_value;

?>


嗯,执行exec(我可以看到,exe文件执行了它必须要做的事情。但它不会回到php脚本。 php脚本

等待应用程序将返回,但它不会返回。在

a特定时间执行执行的时间。


如果我去命令行并执行一个exe文件(同一个

exec调用),然后它没有问题,并立即返回。

但是从exec调用它不会返回。


如何解决这个?好吧,我重新启动服务器。母鸡一切

再次运作。这意味着脚本可以再次使用exec而无需

无限等待。


当问题开始时(当exec开始失败时)服务器可以

仍然没有问题。所有脚本都运行。

不运行的唯一脚本是那些内部有exec调用的脚本。


error.log没有说明这一点。


我在Windows Server 2003上运行apache 2.X.PHP版本是5.x.

停止从c#app返回返回值。 c#app可以

也是一个简单的只有一个console.write(类似echo)。

但是当exec挂起时,这两种方法都不会起作用。 />

有人可以看到问题吗?
return_value;
?>

Well, the exec is executed (I can see that, the exe fil does what it
has to do). But it doesnt return to the php-script. The php-script
waits infinitely that the app will return, but it will not return. At
a certain point the time execution exeedes.

If I go to the command line and execute an exe file (the same one that
exec calls), then it works without problem, and returns immediatly.
But from the exec call it doesnt return.

How do I solve this? Well, I restart the server. And hen everything
works again. Which means that the script can use exec again without
waiting infinitely.

When the problems begin (when the exec begins to fail) the server can
still work without problem. All the scripts run. The only scripts that
dont run are those that have the exec call inside.

error.log doesnt says anything about this.

Im running apache 2.X on windows server 2003. PHP version is 5.x.

I have put log function before and after every single call to exec. I
analyzed it, but I can not understand why the exec fails. It only
stops to get back the return value from the c# app. The c# app can
also be a simple one with only a console.write (something like echo).
But when exec has hanged up neither that will work.

Someone can see the problem?


12月21日,3:01 * pm,wart ... @ hotmail.com写道:
On Dec 21, 3:01*pm, wart...@hotmail.com wrote:

你好


我有一个php网站。某些页面需要调用外部程序。

程序是自制的c#应用程序。


它用于*工作没有问题。一阵子。也许它适用于一些

小时。或者一天。甚至一个星期。


在某个时刻,当php脚本调用exe文件时,

应用程序会冻结。发生以下情况:


< ;?

* *
Hello

I have a php site. Some page needs to call an external program. The
programs are home made c# applications.

It uses to *work without problem. For a while. Maybe it work for some
hour. Or for a day. Or even for a week.

At a certain point, when a php script calls the exe file, the
application freezes. The following happens:

<?
* *


这篇关于exec php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆