我正在尝试在我的meteor项目目录中运行保存在/public/run.bat中的脚本。
在/server/main.js中:
'callExe': function() {
var spawn = require('child_process').spawn,
ls = spawn('cmd.exe', ['/c', 'run.bat']);
ls.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
ls.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
}
这是我得到的错误,
I20160510-00:02:09.762(-4)? stderr: 'run.bat' is not recognized as an
internal or external command,
I20160510-00:02:09.766(-4)? operable program or batch file.
I20160510-00:02:09.766(-4)?
I20160510-00:02:09.794(-4)? child process exited with code 1
虽然它在我放在.meteor \ local \ build \ programs \ server中时运行。 有人可以帮我解决这个问题吗?
答案 0 :(得分:1)
找出run.bat文件的完整路径并使用它。例如,如果run.bat在c:\meteor\local\build\programs\public
ls = spawn('cmd.exe', ['/c', 'c:\meteor\local\build\programs\public\run.bat']);