Is there some way to check the status of a curl command? Say, I have a call to curl from php, using exec to initiate it. Is there a way I can check the progress of it while it's running? Or do I have to wait for it to finish?
exec("curl $url -k > /dev/null 2>&1 &");
You can define a progress function:
curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, 'my_progress_handler');
The name of a callback function where the callback function takes three parameters. The first is the cURL resource, the second is a file-descriptor resource, and the third is length. Return the string containing the data.
For further information, see here.
Attention: This comment disputes PHP's own function signature.
You cannot use exec()
, because it is a blocking function. It will wait, until the program at hand has terminated.
Edit: Oh, I see that you have used the ampersand, nevermind
What you could use is popen()
, but unless curl has a nice way of outputting the progress, this isn't going to be pretty.
I would suggest passing -#
as parameter to curl
, that way you can grab the progress nicely off the output stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With