Something tells me that it is necessary to use callback to get the results of the function, but I can not figure out how to use this method. My code is as follows:
var conn = new Client(); conn.on('ready', function() { conn.exec(execomand, function(err, stream) { if (err) throw err; stream.on('close', function(code, signal) { console.log('Stream closed with code: ' + code + ', signal: ' + signal); conn.end(); }).on('data', function(data) { console.log(data.toString()); }).stderr.on('data', function(data) { console.log('STDERR: ' + data); }); }); }).connect({ host: IPaddress, username: loginname, password: loginpass, port: SSHport });
How do I access the contents of data in the rest of the code?