Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP+cURL disable command line progress output

Tags:

linux

php

curl

I have a PHP script which connects to a remote server with cURL and download some files. I run it thru the command line,

php get.php

Whenever it starts downloading data, I get this output:

Total    % Received % Xferd  Average Speed   Tim Dload  Upload   Total   Spent    Left  Speed
100      162k       0        162k            0   0      21732    0       --:--:-- 0:00:07 --:--:-- 36001

How do I disable it?

like image 930
Roger W. Avatar asked Mar 29 '26 22:03

Roger W.


1 Answers

From the manual refering to CURLOPT_NOPROGRESS:

CURLOPT_NOPROGRESS

TRUE to disable the progress meter for cURL transfers.

Note: PHP automatically sets this option to TRUE, this should only be changed for debugging purposes.

Looks like the progress has been explicitly turned on. Check your code for that option. In any case, if you want to explicitly disable it again, curl_setopt($curlHandle, CURLOPT_NOPROGRESS, true) should do the trick.

Update: If you instead do something like exec("curl http://example.com") you should a) think about what you're doing and b) run curl -s to disable the progress. PHP's streams have support for http, so you can just use file_get_contents, copy et al.

like image 165
Peter Avatar answered Apr 01 '26 09:04

Peter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!