I need to run a an external script by opening it, using curl or some like, but I don't want to wait on it to load, or need to have it's contents. I just want to ping it and have it run itself leaving my operator script free to go on. any advice? Is CURL my best option? Is there something else?
I think you can do it literally by just opening and closing the connection to it $h = fopen('http://www.yoursite.com/file.php', 'r'); fclose($h); PHP:
Hi adbox, You can use img html tag for this (when you don't need any responce nor waiting for it): <img src="http://www.yoursite.com/file.php" height="0" width="0" alt="" /> Code (markup): ^^This line can be echo-ed in php or placed in plain html. Regards, Nick
If you have to do it from server itself, then CURL is best. Fork a background process and its done. If you have to do it from client, method suggested by koko5 makes sense and is used widely.
but does curl attempt to load the contents? I would like 0 wait time if possible, even if the script takes 30 seconds to run. Right now I'm using jays method, any comment on that?
I use file_get_contents() for simple tasks, like getting a specific word or sentence from a dynamic page. I use CURL for more complicated tasks (logins, POSTing binary data and so on), CURL is also faster than anything else. You could launch the script and stop it with Javascript (the script will keep on running on server if ignore_user_abort(true); is set)
CURL is the best option where you want to run process in background and also need multiple threads.. In fact, if you have CURL, I believe you won't need anything else..
Then you need to do the fetch in the background. Depending on what you want to do with the results, the easiest way is to just do it in an iframe. That way the rest of the page will draw, and the curl-dependent content will fill in when it's available. Otherwise, if you want to be fancier, you can use the curl_multi functions to perform a transfer in the background while your program gets on with other things. Then, you can flush the output buffer and wait around for the curl operation to complete if it hasn't already. If you've never dealt with async calls this might initially be a frustrating journey but once you get your head around it you'll be more powerful than ever.
what is the use of curl? can anybody explain it?? whether is curl is extension of PHP or some other language??
curl is linux service, i think... you can use it for downloading pages/files, you can use cookies, proxies, send post data, etc. etc. theres a lot of things you can do with curl, here are options: http://www.php.net/manual/en/function.curl-setopt.php
@insert Curl is also compiled for Windows platform @hasanbasri http://w3schools.com/html/html_images.asp, but in current situation, its used for opening a URL
You don't want to display the file you just want to run it. Simple enough answer is to set a CRON job, or a Scheduled Task. Any decent host should offer this.
file_get_contents() is to simply get the literal source code (html) from a webpage. Curl is not only faster, but it allows for more options. You can send POST values using curl among other things. If you just want to run it, file_get_contents or fopen() aren't bad choices, just don't echo the contents if you don't want to see them.