Re: out-format in one line

Wayne Davison via rsync <[email protected]>
Newsgroups gmane.network.rsync.general
Message-ID <CAHSx_Stu7ObYrd+dK_kAQh7wt3D-POagUi-rUM8OThkmUYG+AQ@mail.gmail.com>
On Sat, Jan 28, 2023 at 1:22 AM Michael Homscheidt wrote:

> I use rsync with the option --out-format '%o %n‘ but want to have the
> contents of the mesages to be overwritten.


You can't make rsync do that directly, but you can filter the output.  For
instance, the following python3 script runs rsync with an --out-format that
starts with "<>" and filters the combined stdout + stderr output, putting
repeated "<>" lines over the top of each other (using ANSII reverse-index &
clear-to-EOL escape sequences). It also allows error/info lines to remain
visible: they do not overwrite the prior merged line and a new merged line
starts below it. If a line is too long to fit on a single terminal line
then there will be some downward movement, but that could be improved
should you desire to do so.

Name this script something like "solo-rsync":

#!/usr/bin/python3
import sys, subprocess
                                                    rsync =
subprocess.Popen(
        ['rsync', '--outbuf=line',
            '--out-format=<>%o %n',
            *sys.argv[1:]],
        stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
        encoding='UTF-8')
folding = False
for line in rsync.stdout:
    if line.startswith('<>'):
        if folding:
            print("\033[A" + line[2:].rstrip("\n") + "\033[K")
        else:
            print(line[2:], end='')
            folding = True
    else:
        print(line, end='')
        folding = False
    sys.stdout.flush()

..wayne..

-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.