s3cmd icon indicating copy to clipboard operation
s3cmd copied to clipboard

Streaming "get" prints logging info to STDOUT instead of STDERR

Open riskhanna opened this issue 9 years ago • 2 comments

In version >1.6, when you using the streaming get functionality (s3cmd get s3://BUCKETNAME -), there is some logging information that is printed to STDOUT instead of STDERR that prevents me from piping the data to other tools (for example, piping json data to jq).

$ s3cmd get s3://rishi-test-s3cmd/test.txt - 2> /dev/null
download: 's3://rishi-test-s3cmd/test.txt' -> '-'  [1 of 1]
download: 's3://rishi-test-s3cmd/test.txt' -> '-'  [1 of 1]
Hello, World
My name is Rishi
 30 of 30   100% in    0s   165.59 B/s  done

Can this be altered so that logging info is printed to STDERR?

riskhanna avatar Jan 12 '17 19:01 riskhanna

I looked at this a bit last night. First, replacing stdout with a new file descriptor to /dev/null, when --quiet is sent, is the wrong thing to do. This is addressed in new branch bug/stdout for consideration: https://github.com/s3tools/s3cmd/tree/bug/stdout

Now when using get --quiet, all output() messages are not emitted. There is still one progress message getting printed which I haven't figured out why.

We've got a couple choices:

  1. Omit printing these status messages to stdout when destination for a file is stdout (effectively what --progress/no-progress does)
  2. Print these status messages to stderr instead

With the above branch, and --quiet --no-progress, I get the desired result - no progress message is printed, and the stdout contains the file just downloaded. I'd prefer for that last status message, with 'done' on the end, to automatically not be printed, just like the other status messages aren't printed. Need to see why that's happening...

mdomsch avatar Feb 07 '17 13:02 mdomsch

Fixed by #1315.

ctrlcctrlv avatar Mar 18 '23 23:03 ctrlcctrlv