node-rsync
node-rsync copied to clipboard
How do I get progress output? Only seeing <Buffer ..... in stdout
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..
Just found a solution: console.log(data.toString('utf-8'));
more info here https://docs.nodejitsu.com/articles/advanced/buffers/how-to-use-buffers/
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
});