I'm using the scp command in a node application to transfer a file to a server; I've not been able to show in console the progress while transferring, as "scp" normally does if you use it in the shell manually; here is my code:
//require system modules
var spawn = require('child_process').spawn;
console.log("copy begins...");
var executor = spawn("scp", ["-r", ".tmp/app.tar.gz", "user@server:/home/user"]);
executor.stderr.on('data', function(data) {
console.log(data.toString());
});
executor.stdout.on('data', function(data) {
console.log(data.toString());
});
executor.stdout.on('end', function(data) {
console.log("copied");
});
executor.on('close', function(code) {
if (code !== 0) {
console.log('Failed: ' + code);
}
});
This just logs in the console "copy begins..." and "copied", but nothing else; is it possible to get the output of the scp command during its execution and send it to the console?