Open mmumshad opened 7 years ago
When I try to write a file with contents as given in example, it comes back with error:
C:\ .... node_modules\scp2\lib\client.js:228 throw new Error('Content should be buffer or file descriptor');
My code
createFileOnScriptEnginer = function(contents,destinationPath){ var Client = require('scp2').Client; var cl = new Client({ port: 22, host: "10.xxx.xxx.131", username: "root", privateKey: require('fs').readFileSync("server/components/ssh/ssh_key"), }); cl.write({ destination: destinationPath, content: contents }, function(err){ }) }; createFileOnScriptEnginer('sdfdddddddddsfd','/tmp/testfile.txt');
And the I tried to create Buffer like below. And this time it creates the file but program hangs.
exports.createFileOnScriptEnginer = function(contents,destinationPath){ var Client = require('scp2').Client; var buffer = new Buffer(contents, "utf-8") var cl = new Client({ port: 22, host: "10.xxx.xxx.131", username: "root", privateKey: require('fs').readFileSync("server/components/ssh/ssh_key"), }); cl.write({ destination: destinationPath, content: buffer }, function(err){ }) };
When I try to write a file with contents as given in example, it comes back with error:
My code
And the I tried to create Buffer like below. And this time it creates the file but program hangs.