1

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.

1
  • Please, clarify, do you need solution in javascript or php? Commented Feb 6, 2011 at 6:14

4 Answers 4

2

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.

https://www.php.net/curl

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

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?

Comments

0

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
                });
            });
        });
    });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.