Redirect --stats to STDERR.

Benoît LORAND benoit.lorand at blorand.org
Tue Feb 6 18:32:42 GMT 2007


Hello,

    I have written a little script that's would email me all errors.
          rsync -vah --delete --stats <sources> <destination> > 
/var/log/sauvegarde/listoffile.log 2> /var/log/sauvegarde/errors.log

    My problem is i want to have the stats in my mail. Is it possible to 
redirect --stats to STDERR.

    I have tryed to do this :

                    /--- rsync-2.6.9/main.c  2006-10-14
                    01:46:32.000000000 +0200/
                    /+++ rsync-2.6.9.new/main.c      2007-02-06
                    19:28:08.000000000 +0100/
                    /@@ -227,39 +227,39 @@/
                    / {/
                    /        if (do_stats) {/
                    /                rprintf(FCLIENT, "\n");/
                    /-               rprintf(FINFO,"Number of files:
                    %d\n", stats.num_files);/
                    /-               rprintf(FINFO,"Number of files
                    transferred: %d\n",/
                    /+               rprintf(FERROR,"Number of files:
                    %d\n", stats.num_files);/
                    /+               rprintf(FERROR,"Number of files
                    transferred: %d\n",/
                    /                        stats.num_transferred_files);/
                    /-               rprintf(FINFO,"Total file size: %s
                    bytes\n",/
                    /+               rprintf(FERROR,"Total file size: %s
                    bytes\n",/
                    /                        human_num(stats.total_size));/
                    /-               rprintf(FINFO,"Total transferred
                    file size: %s bytes\n",/
                    /+               rprintf(FERROR,"Total transferred
                    file size: %s bytes\n",/
                    /                       
                    human_num(stats.total_transferred_size));/
                    /-               rprintf(FINFO,"Literal data: %s
                    bytes\n",/
                    /+               rprintf(FERROR,"Literal data: %s
                    bytes\n",/
                    /                       
                    human_num(stats.literal_data));/
                    /-               rprintf(FINFO,"Matched data: %s
                    bytes\n",/
                    /+               rprintf(FERROR,"Matched data: %s
                    bytes\n",/
                    /                       
                    human_num(stats.matched_data));/
                    /-               rprintf(FINFO,"File list size:
                    %d\n", stats.flist_size);/
                    /+               rprintf(FERROR,"File list size:
                    %d\n", stats.flist_size);/
                    /                if (stats.flist_buildtime) {/
                    /-                       rprintf(FINFO,/
                    /+                       rprintf(FERROR,/
                    /                                "File list
                    generation time: %.3f seconds\n",/
                    /                               
                    (double)stats.flist_buildtime / 1000);/
                    /-                       rprintf(FINFO,/
                    /+                       rprintf(FERROR,/
                    /                                "File list transfer
                    time: %.3f seconds\n",/
                    /                               
                    (double)stats.flist_xfertime / 1000);/
                    /                }/
                    /-               rprintf(FINFO,"Total bytes sent:
                    %s\n",/
                    /+               rprintf(FERROR,"Total bytes sent:
                    %s\n",/
                    /                        human_num(total_written));/
                    /-               rprintf(FINFO,"Total bytes
                    received: %s\n",/
                    /+               rprintf(FERROR,"Total bytes
                    received: %s\n",/
                    /                        human_num(total_read));/
                    /        }/

                    /        if (verbose || do_stats) {/
                    /                rprintf(FCLIENT, "\n");/
                    /-               rprintf(FINFO,/
                    /+               rprintf(FERROR,/
                    /                        "sent %s bytes  received %s
                    bytes  %s bytes/sec\n",/
                    /                        human_num(total_written),
                    human_num(total_read),/
                    /                        human_dnum((total_written +
                    total_read)/(0.5 + (endtime - starttime)), 2));/
                    /-               rprintf(FINFO, "total size is %s 
                    speedup is %.2f\n",/
                    /+               rprintf(FERROR, "total size is %s 
                    speedup is %.2f\n",/
                    /                        human_num(stats.total_size),/
                    /                        (double)stats.total_size /
                    (total_written+total_read));/
                    /        }/


But the problem is i have an error 23 when i use rsync.




More information about the rsync mailing list