Answer the question
In order to leave comments, you need to log in
How to redirect a stream and write data to a variable?
Good afternoon, I'm trying to understand node, the task arose to get data from the server via ssh using the "ssh-exec" module.
Example code:
var exec = require('ssh-exec');
exec('who', {
user: 'user',
host: '192.168.1.1',
password: 'password'
}).pipe(process.stdout)
Answer the question
In order to leave comments, you need to log in
I think that you need to use the second example, where there is a callback. Something like this:
var exec = require('ssh-exec')
exec('ls -lh', {
"user": "de1m",
"host": "localhost",
"password": "pass"
}, function (err, stdout, stderr) {
console.log(err, stdout, stderr)
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question