Discussion:
pipe vs. tty: output is different: curl -v google.com vs. curl -v google.com | cat
Henrique Vicente de Oliveira Pinto
2018-06-15 14:11:48 UTC
Permalink
Hi,

I'm trying to understand what is happening here...

If I pipe the curl output to another process, I get a different output than
if curl prints directly on stdout.

Example / How to reproduce:

1. curl -v google.com
2. curl -v google.com | cat
then diff both outputs.

On the second time besides getting the multiline progress bar I get some
extra info (especially when using --verbose) -- mostly, lots of "{ [219
bytes data]" blocks.

I have tried using --trace and --trace-ascii to avoid getting such info
lines but failed to figure out how to do so.

Question: What would be the most straight-forward way for me to get exactly
the same output I get when I use curl directly?

This code seems to be the culprit, but I haven't gone deeper into the
matter:

https://github.com/curl/curl/blob/c45360d4633850839bb9c2d77dbf8a8285e9ad49/src/tool_cb_dbg.c#L141-L153

Best regards,

Henrique Vicente
https://henvic.github.io/
https://github.com/henvic
http://flickr.com/photos/henriquev/
Daniel Stenberg
2018-06-16 22:49:28 UTC
Permalink
Post by Henrique Vicente de Oliveira Pinto
If I pipe the curl output to another process, I get a different output than
if curl prints directly on stdout.
1. curl -v google.com
2. curl -v google.com | cat
then diff both outputs.
On the second time besides getting the multiline progress bar I get some
extra info (especially when using --verbose) -- mostly, lots of "{ [219
bytes data]" blocks.
In the second case, curl determines that you're not sending the output to the
terminal, stdout or stderr so the verbose info shows something about the data
that it passes on.
Post by Henrique Vicente de Oliveira Pinto
I have tried using --trace and --trace-ascii to avoid getting such info
lines but failed to figure out how to do so.
That output is part of the verbose output logic enabled with -v, whereas
--trace and --trace-ascii show it differently.
Post by Henrique Vicente de Oliveira Pinto
Question: What would be the most straight-forward way for me to get exactly
the same output I get when I use curl directly?
curl doesn't give you that option to my recollection. When you get the output
to the terminal or "in your face" you get to see the data so I've reasoned
that there's then no point in telling that it received data!
--
/ daniel.haxx.se
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/eti
Loading...