I'm trying to copy system activity report(SAR) of a remote machine to a local machine using NodeJS ssh-exec utility, something like below.
Program code:-
var exec = require('ssh-exec');
var fs = require('fs');
var writeStream = fs.createWriteStream('sar.txt');
exec('LC=ALL sar -A -f /var/log/sa/sa13', {user:"thiru",host:"192.168.56.1",password:"xxxx"}).pipe(writeStream);
Problem:-
While executing the above code,every time the order of the content is getting varied.I believe all these are happening because of node asych behavior, is it is possible to copy the remote content synchronously using some way?