I'm running a simple rsync script where I log stdout and stderr to two different files, rsync_stdout.log and rsync_stderr.log.

When I'm trying to email the content of rsync_stderr.log using:

echo $(cat rsync_stderr.log) | ssmtp myaddress@gmail.com

I get a blank email body, but when I do:

echo $(cat rsync_stdout.log) | ssmtp myaddress@gmail.com

then I have my stdout log in the body of the email without problem.

Is it something to do with rsync's stderr output file?

I ran ssmtp as verbose:

[<-] 250 2.1.5 OK b48smxxx70wrb.1 - gsmtp
[->] DATA
[<-] 354  Go ahead b48smxxxxxx70wrb.1 - gsmtp
[->] Received: by XXXNAS (sSMTP sendmail emulation); Tue, 19 Dec 2017 01:14:47 +0100
[->] From:"XXXNAS" <XXXNAS>>
[->] Date: Tue, 19 Dec 2017 01:14:47 +0100
[->] rsync: delete_file: unlink(.AppleDB/log.0000000001) failed: Permission denied (13)
[->] rsync: delete_file: unlink(.AppleDB/lock) failed: Permission denied (13)
[->] rsync: delete_file: unlink(.AppleDB/db_errlog) failed: Permission denied (13)
[->] rsync: delete_file: unlink(.AppleDB/cnid2.db) failed: Permission denied (13)
[->] rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) 
[->] [sender=3.1.2]
[->] .
[<-] 250 2.0.0 OK 1513642487 b48sxxxxxxrb.1 - gsmtp
[->] QUIT
[<-] 221 2.0.0 closing connection b4xxxxxwrb.1 - gsmtp

So I can see the text being sent, but the email's body just comes blank.

I also tried ssmtp myaddress@gmail.com < rsync_stderr.log but it doesn't work either.

  • Do you mean without the space between "<" and "file.log" ? – brunobhr Sep 17 '18 at 15:27
  • Sorry, I must have missed reading the very last line of the question where you said you already tried this. – Kusalananda Sep 17 '18 at 15:29

After user almendrico put me on the path, I used:

sed 's/[\:]//g' to remove the : character.

Not very elegant but works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.