Search code examples
curlresponsepopen

Why there is difference in curl outputs?


the code snippet given here gives me the output as

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    56    0    32  100    24    461    346 --:--:-- --:--:-- --:--:--   463
{"success": true}

but when i give the same curl command directly in the terminal it gives me output as

{"success": true}

only.

So why there is difference between these outputs? I just want the response i.e. {"success": true} here. I don't want rest of the data. How should i do that ?

Curl full command which i was using is: curl -X POST -d '{"device_id": "181CBBE"}' http://www.example.com/get_device_details


Solution

  • the summary goes to stderr and the response goes to stdout; your popen command only returns stdout; use curl -s to suppress the summary