Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
meteorJS从服务器调用shell命令_Shell_Meteor - Fatal编程技术网

meteorJS从服务器调用shell命令

meteorJS从服务器调用shell命令,shell,meteor,Shell,Meteor,我用的是MeteorJS 我想从javascript服务器端调用bash命令。对于nodeJS,这似乎是可能的: 然而,我找不到与meteorJS类似的东西。我想要这样的东西: if(Meteor.isServer){ ... exec("myCommand"); } 如果您从示例中获取所需的呼叫并在其前面加上前缀 var sys = __meteor_bootstrap__.require('sys'); 它应该可以工作。您也可以使用child\u process.spawn() s

我用的是MeteorJS

我想从javascript服务器端调用bash命令。对于nodeJS,这似乎是可能的:

然而,我找不到与meteorJS类似的东西。我想要这样的东西:

if(Meteor.isServer){
...

exec("myCommand");
}

如果您从示例中获取所需的呼叫并在其前面加上前缀

var sys = __meteor_bootstrap__.require('sys');

它应该可以工作。

您也可以使用child\u process.spawn()

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')