Skip to content

"rclone cat" doesn't work with "--progress" #3743

Open

Description

@Blaok

What is the problem you are having with rclone?

rclone cat foo:bar --progress won't work. It should write the content of foo:bar to stdout, yet it writes the progress reports.

What is your rclone version (output from rclone version)

rclone v1.50.1-DEV
- os/arch: linux/amd64
- go version: go1.10.4

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Ubuntu 18.04

Which cloud storage system are you using? (eg Google Drive)

Doesn't matter

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone cat foo:bar --progress

A log from the command with the -vv flag (eg output from rclone -vv copy /tmp remote:tmp)

DEBUG : Using config file from "xxx"
DEBUG : 5 go routines active
DEBUG : rclone: Version "v1.50.1-DEV" finishing with parameters ["rclone" "cat" "foo:bar" "-vv" "--progress"]

Activity

  1. ncw commented on Nov 17, 2019

    @ncw
    Member

    Are you saying that you think the output of --progress should be to stderr rather than stdout?

    I suppose that would work and there are tools like pv which read on stdin and write on stdout but still display stuff on the terminal.

    This would be quite easy to change but I wonder if it might break people's workflows...

    Should it be configurable?

    Thoughts and examples of what other unix commands do appreciated!

  2. added this to the v1.51 milestone on Nov 17, 2019
  3. ncw commented on Nov 17, 2019

    @ncw
    Member

    Interesting thanks @Yexiaoxing

    This is a bit of advice rclone should probably be following too

    With that in mind, I recommend writing progress counters only after checking whether the stream is interactive (e.g., with isatty()) or when explicitly enabled by a command-line option. That’s especially important for progress meters that rely on terminal update behavior to make sense, like %-complete bars.

    One irritation moving the --progress output to stderr would be the interaction with --log-file.

    Rclone currently redirects stderr to the log-file. It does this so the logfile can capture panic backtraces - as far as I know you can't redirect these away from stderr in Go. See https://stackoverflow.com/q/34772012/164234 for info (top answer is mine!).

  4. Blaok commented on Nov 17, 2019

    @Blaok
    Author

    Thanks for your reply (and for this amazing project!). Yes, I think making the output of --progress go to stderr would be better. An alternative would be to disable progress report if stdout is redirected (not a terminal), but that would make it impossible to see the progress of rclone cat of a very large file (which is my use case).

    About the interaction with --log-file, I agree it is not very compatible with --progress on stderr. However, I doubt if they would be used together. If someone is redirecting stderr to a logfile, I'd assume it is used in a script so the terminal output is unlikely to be monitored and I wouldn't expect --progress is used. If --progress and --log-file have to be used together, I'd say we need a separate process to write the progress on stderr...

  5. modified the milestones: v1.51, v1.52 on Feb 1, 2020
  6. modified the milestones: v1.52, v1.53 on May 29, 2020
  7. modified the milestones: v1.53, v1.54 on Sep 5, 2020
  8. ivandeex commented on Nov 16, 2020

    @ivandeex
    Member

    Having data, log and statistics on well-known file descriptors is also important for seamless integration with automatic tools and workflows. Labeling this with integration.

  9. 1 remaining item

  10. added this to the v1.55 milestone on Feb 3, 2021
  11. modified the milestones: v1.55, v1.56 on Apr 3, 2021
  12. modified the milestones: v1.56, v1.57 on Jul 20, 2021
  13. modified the milestones: v1.57, Known Problem on Nov 1, 2021
  14. Sarke commented on Jun 2, 2022

    @Sarke

    With that in mind, I recommend writing progress counters only after checking whether the stream is interactive (e.g., with isatty()) or when explicitly enabled by a command-line option. That’s especially important for progress meters that rely on terminal update behavior to make sense, like %-complete bars.

    I agree with this. I would expect to see the progress updated to the terminal, even if I pipe stdout somewhere else. I don't see the use-case for it to be printed every other line in an output file.

    I posted this in the forum, on possible ways to solve this:

    1. change it to use stderr (possible bc break if anyone is relying on it somehow)
    2. provide an option to use stderr for the progress and other info.
    3. detect when output is not going to terminal (but being piped), and only then use stderr/terminal for the additional info
  15. ncw commented on Jun 7, 2022

    @ncw
    Member

    The relevant forum thread is here: https://forum.rclone.org/t/redirect-progress-to-stderr/31066/

    I think this is the best idea so far

    What you are asking for there is rclone to write the progress direct to the console, rather than to stdout. This is (for example) how some programs prompt for passwords. If rclone did that then you could redirect stdout to a file and still see the progress.

    This looks to be how you do it - write the progress to /dev/tty - that makes it unaffected by redirects of stdout or stderr.

    https://stackoverflow.com/a/45766289/164234

    Fancy having a go at implementing it?

  16. edquist commented on Sep 30, 2022

    @edquist

    A simple idea - just have the terminal library (which --progress uses) send its output to stderr instead of stdout.

    See PR #6474.

  17. avollmerhaus commented on Nov 19, 2025

    @avollmerhaus

    This hit me today:

    rclone --progress cat "$S3URL" | zstd  --decompress | tar xf -
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions