我正在使用MeteorJS。meteorJS從服務器調用shell命令
我想從javascript服務器端調用bash命令。這似乎可能與nodeJS: http://www.dzone.com/snippets/execute-unix-command-nodejs
但是,我找不到與meteorJS類似的東西。我想這樣的事情:
if(Meteor.isServer){
...
exec("myCommand");
}
我正在使用MeteorJS。meteorJS從服務器調用shell命令
我想從javascript服務器端調用bash命令。這似乎可能與nodeJS: http://www.dzone.com/snippets/execute-unix-command-nodejs
但是,我找不到與meteorJS類似的東西。我想這樣的事情:
if(Meteor.isServer){
...
exec("myCommand");
}
如果你把電話從樣品要求,並與
var sys = __meteor_bootstrap__.require('sys');
它應該工作前綴他們。
您也可以使用child_process.spawn()。
Read More about executing a UNIX command with Meteor。
spawn = Npm.require('child_process').spawn;
command = spawn('ls', ['-la']);
command.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
command.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
command.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
從Meteor 0.6.0開始它就像'var sys = Npm.require('sys');'' – emgee