0
var restify = require('restify');
var rexec = require('remote-exec');
function respond(req, res, next) {
var connection_options = {
username: 'root',
passphrase: 'xxxxx'
};
var hosts = [
'n.n.n.n'];
var cmds = [
'ls -l',
'cat /etc/hosts'];
console.log('Recieved Request');
rexec(hosts, cmds, connection_options, function (err) {
console.log(34455);
if (err) {
console.log(err);
} else {
console.log('Great Success!!');
}
res.send('Wait..');
});
// res.send('hello ' + req.params.name);
}
var server = restify.createServer();
server.get('/hello/:name', respond);
server.head('/hello/:name', respond);
server.listen(8080, function() {
console.log('%s listening at %s', server.name, server.url);
});
執行使用代碼在遠程系統終端命令工作但這不工作,我失去的東西嗎?還有一件事是節點服務器正在運行,而我試圖連接的遠程IP都是一樣的。