Why is there no stderr and stdout output?

When launching the command rclone copy -vc --stats=10s --dry-run Desktop/test/os/linux/ dropbox: 2>rclone_errors.txt | tee rclone.txt, no output is displayed on screen and exists on completion.

However when the command rclone copy -vc --stats=10s --dry-run Desktop/test/os/linux/ dropbox: 2>&1 | tee rclone.txt, it returns the information to the screen.

Why is there a difference?

1 Like

The difference is related to what you are redirecting. You can find a good explanation documented up here:

@Animosity022, the use of 2>rclone_errors.txt should not limit stdout as the former command is only redirecting stderr messages to a specific location.

The first one you redirect stderr to a file so it wasn't shown.

The second one you took stderr and put it back to stdout, which is why the stats were displayed.

felix@gemini:~$ rclone copy /etc/hosts GD: -vc --stats=10s --dry-run 2>blah.txt
felix@gemini:~$ cat blah.txt
2020/01/06 12:43:27 INFO  :
Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 0
Checks:                 1 / 1, 100%
Transferred:            0 / 0, -
Elapsed time:          0s

felix@gemini:~$ rclone copy /etc/hosts GD: -vc --stats=10s --dry-run 2>&1
2020/01/06 12:43:39 INFO  :
Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 0
Checks:                 1 / 1, 100%
Transferred:            0 / 0, -
Elapsed time:          0s

Sorry, I am confused. Why is rclone's output stderr as opposed to stdout?

I'm not sure as it was written to log most things to stderr.

I'd just use --log-file if that is the goal.

Thanks. Maybe @ncw should shed light on the topic since it's uncommon (it's the first time I have experienced it and it had me question the syntax of the command, not that it's bad to question oneself).

The log goes to stderr, output from the command goes to stdout. Most commands don't have any output, but some do like rclone size or rclone ls.

Thanks. Do you mean that rclone copy -vc --stats=10s --dry-run Desktop/test/os/linux/ dropbox: 2>rclone_errors.txt | tee rclone.txt would have produce an output to stdout?

rclone copy does't produce any output to stdout so I would expect the above to print nothing.

I think what he's asking is that command does produce output but it writes to stderr rather than stdout.

felix@gemini:/opt/rclone/scripts$ rclone copy /etc/hosts GD: -vc --stats=10s --dry-run
2020/01/07 07:18:55 NOTICE: hosts: Not copying as --dry-run
2020/01/07 07:18:55 INFO  :
Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 0
Checks:                 0 / 0, -
Transferred:            1 / 1, 100%
Elapsed time:          0s

felix@gemini:/opt/rclone/scripts$ rclone copy /etc/hosts GD: -vc --stats=10s --dry-run 2>blah.txt
felix@gemini:/opt/rclone/scripts$ cat blah.txt
2020/01/07 07:19:07 NOTICE: hosts: Not copying as --dry-run
2020/01/07 07:19:07 INFO  :
Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 0
Checks:                 0 / 0, -
Transferred:            1 / 1, 100%
Elapsed time:          0s

That's correct. Why does it write it to stderr?

It is standard for unix tools to write their log messages to stderr so you can redirect them elsewhere.

To clarify, do you mean to say that the display below is considered to be log information?

2020/01/07 07:18:55 NOTICE: hosts: Not copying as --dry-run
2020/01/07 07:18:55 INFO  :
Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 0
Checks:                 0 / 0, -
Transferred:            1 / 1, 100%
Elapsed time:          0s

That is correct. All log messages will start Date time LEVEL. The stats log is multi line.

@ncw Sorry for butting in, but shouldn't this be in the stdout instead of stderr?

Its arguable probably, however I don't think anyone has complained about it in the last 7 years!

@ncw, it isn't a complaint :smile: rclone is an amazingly well designed application. I raised it as the behavior was different to other applications and was curious as to whether there was a specific reason for the decision.

:smiley:

Probably consistency as all the message are sent to the log rather than to stdout unless they are something the user specifically asked for (like a listing).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.