【发布时间】:2016-06-06 23:20:51
【问题描述】:
我正在使用 Node.js SSH2 模块(https://github.com/mscdex/ssh2)。 myScript.py 连续执行。如何在保持 SSH 连接处于活动状态的同时停止它?
var Connection = require('ssh2');
var c = new Connection();
c.on('ready', function() {
c.exec('python myScript.py', function(err, stream) {
if (err) throw err;
stream.on('data', function(data, extended) {
//this callback gets called multiple times as the script writes to stdout
console.log((extended === 'stderr' ? 'STDERR: ' : 'STDOUT: ') + data);
allData+=data;
});
});
});
c.connect({
host: xxx.xxx.x.xx,
port: 22,
username: 'user',
password: 'pass'
});
【问题讨论】: