运行并忘记php中的系统调用
所以我试图从我的 php 代码执行一些脚本。它位于 blah.php 页面中,
<?php
// ....
// just basic web site that allows upload of file...
?>
在里面我使用系统调用,
if (system("blah.pl arg1") != 0)
{
print "error\n";
}
else
{
print "working on it..you will receive e-mail at completion\n";
}
效果很好,但它会等到它完成后再打印它的工作。 我知道我从 php 调用 perl 脚本不是一个拼写错误。
我怎样才能开始程序执行并让它在后台完成。 blah.pl 脚本处理电子邮件通知。
有人吗?
谢谢我很感激
So I am trying to execute some script from my php code. That lives in page blah.php
<?php
// ....
// just basic web site that allows upload of file...
?>
Inside I use system call
if (system("blah.pl arg1") != 0)
{
print "error\n";
}
else
{
print "working on it..you will receive e-mail at completion\n";
}
Works great but it waits until it completes until it prints working on it.
I am aware that I am calling perl script from php not a typo.
How can I just start program execution and let it complete in background.
The blah.pl script handles e-mail notification.
Anyone?
Thanks I appreciate it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自 system 函数文档:
只需重定向 Perl 脚本的输出,PHP 就应该能够运行,而无需等待脚本完成。
From system function documentation:
Simply redirect the output of your Perl script and PHP should be able to run without having to wait for the script to finish.
您可以添加一个&符号来在后台生成该进程吗?
Can you add an ampersand to spawn the process in the background?
您可能可以使用 popen 函数
http://www.php.net/manual /en/function.popen.php
You could probably use the popen function
http://www.php.net/manual/en/function.popen.php
由于所有 PHP 命令行函数都等待结果 - 我建议您有一个单独的页面来调用电子邮件脚本。
换句话说,使用 cURL 或文件包装器向 email.php 页面(或其他页面)发送请求,这允许您在接收结果之前关闭连接。所以这个过程看起来像这样。
Since all the PHP command line functions wait for a result - I recommend that you have a separate page to call the emailer script.
In other words, send a request to the email.php page (or whatever) using cURL or the file wrappers which allows you to close the connection before receiving a result. So the process will look something like this.