In trying to write a nice GUI for rsync, it was difficult to read rsync's stdout when using --progress, as --progress uses \r to make things pretty on a terminal, but it's painful to read into another process. The attached patch made it much easier for me to read and parse the output from --progress by adding a command-line option --progress-newline, which simply causes --progress to use \n instead of \r for eol to ease reading stdout. I hope this is useful. -------------- next part -------------- A non-text attachment was scrubbed... Name: progress-newline.patch Type: application/octet-stream Size: 4756 bytes Desc: not available Url : http://lists.samba.org/archive/rsync/attachments/20060511/e2d10035/progress-newline.obj
On Thu 11 May 2006, Ryan T. Sammartino wrote:> In trying to write a nice GUI for rsync, it was difficult to read > rsync's stdout > when using --progress, as --progress uses \r to make things pretty on > a terminal, > but it's painful to read into another process.Well... shouldn't be that much of a problem? Putting this tr command in the pipe should help: tr '\r' '\n'> The attached patch made it much easier for me to read and parse the output > from > --progress by adding a command-line option --progress-newline, which simply > causes --progress to use \n instead of \r for eol to ease reading stdout.A bigger issue may be that output is buffered when writing into a pipe, which means you only get rsync's output when the buffer is full. This is referred to in (long-standing) Debian bug #48108 (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=48108). Paul Slootman
> Well... shouldn't be that much of a problem? Putting this tr command in > the pipe should help:> tr '\r' '\n'You assume I am working in a sane environment. :)> A bigger issue may be that output is buffered when writing into a pipe, > which means you only get rsync's output when the buffer is full.Yes, that is exactly this issue (sorry, my original message wasn't very clear, which is what I get for sending e-mail at 2:30 AM). Nothing appears in stdout until either a very long time has passed or the file has completed, which is fairly useless when trying to make a pretty progress bar for the command-line challenged.> This is referred to in (long-standing) Debian bug #48108 (see > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=48108).Hmm. Now why didn't Google turn that up for me? Anyways, that's a nicer way of doing it, it seems... again, coding at 2:30 AM is not advised. I'd vote for that patch (or something like it that also includes updating the man page, etc) to be included (not that my vote counts for anything). Cheers.
Maybe Matching Threads
- [Bug 1189] New: Include of a file not robust to missing newline at EOF
- Read.dcf with no newline ending: gzfile drops last line
- R CMD BATCH on scripts without trailing newline
- [Bug 1302] scp failes to copy a file with newline
- Last line in .Rprofile must have newline (PR#4056)