node-rsync icon indicating copy to clipboard operation
node-rsync copied to clipboard

How do I get progress output? Only seeing <Buffer ..... in stdout

Open yuchant opened this issue 6 years ago • 2 comments

I enabled progress: var rsync = new Rsync().progress()

Added stdout handler in rsync.execute, and all I see in output is:

<Buffer 20 20 20 20 20 20 36 35 38 38 36 36 20 20 35 35 25 20 20 36 34 33 2e 34 32 6b 42 2f 73 20 20 20 20 30 3a 30 30 3a 30 30 0d>

Thanks all..

yuchant avatar Mar 27 '18 01:03 yuchant

Just found a solution: console.log(data.toString('utf-8')); more info here https://docs.nodejitsu.com/articles/advanced/buffers/how-to-use-buffers/

AndrewPix avatar Apr 07 '18 13:04 AndrewPix

Here's a more complete example:

var Rsync = require('rsync');

// Build the command
var rsync = new Rsync()
  .shell('ssh')
  .flags('az')
  .source('/path/to/source')
  .destination('server:/path/to/destination')
  .output(
    function (data) {
      console.log(data.toString('utf-8'));
    },
    function (data) {
      console.log(data.toString('utf-8'));
    }
  );

// Execute the command
rsync.execute(function(error, code, cmd) {
    // we're done
});

drdogbot7 avatar Dec 11 '20 21:12 drdogbot7