executing remote php scripts consecutively

发布于 2022-09-05 15:42:56 字数 576 浏览 28 评论 0

I have a couple php scripts on remote web servers and I'm not sure how to create a local script that will execute those remote scripts consecutively (a delay between each one of a few seconds would be fine) and then proceed with the execution of the local php script (which analyzes the information gathered by the remote scripts).

At the moment I use iframes just to run the remote scripts, but I'd prefer not to.

I'm assuming I can use javascript to do this, but while I can program PHP/MySQL with some success - I'm lost when it comes to javascript.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

清晰传感 2022-09-12 15:42:56

You could use cURL in PHP. It will make an http request and wait for the result, then use sleep() to space out the executions.

http://us3.php.net/curl

梦里泪两行 2022-09-12 15:42:56

If you know all URLs beforehead, you may use something like this:

var data = [];
$.when( $.ajax("url1.php") ).then(function(ajaxArgs){
data.push(ajaxArgs);
$.when( $.ajax("url2.php") ).then(function(ajaxArgs){
data.push(ajaxArgs);
$.when( $.ajax("url3.php") ).then(function(ajaxArgs){
data.push(ajaxArgs);
// process data
})
})
});

with jQuery 1.5 http://api.jquery.com/jQuery.when

凌乱心跳 2022-09-12 15:42:56

Depending on your OS and your server's OS, you could do something like this from cron:

ssh user@host '/usr/bin/php /path/to/script.php'

You could also just run it directly on the server via cron:

/usr/bin/php /path/to/script.php

Alternatively, you could use wget or curl to run the script via Apache/your-fav-web-server. Though, the above method has benefits such as easily getting an email of the script errors.

Perhaps give a little more info:
* remote server OS?
* server shell access?
* workstation/local server OS?

呆橘 2022-09-12 15:42:56

if you use jquery you can try something like

$(function(){
    $.get('http://youraddress/script1.php',function(){
        $.get('http://youraddress/script2.php',function(){
            $.get('http://youraddress/script3.php',function(){
                $.get('http://youraddress/script4.php',function(){
                    //you are done
                });
            });
        });
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文