Reputation: 405
I am trying to run a script saved in /public/run.bat in my meteor project directory.
In /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);
});
}
This is the error I get,
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
Though it runs when I place it in .meteor\local\build\programs\server. Can someone help me resolve this?
Upvotes: 1
Views: 455
Reputation: 11702
Find out the full path to your run.bat file and use it. For example if run.bat is in c:\meteor\local\build\programs\public
ls = spawn('cmd.exe', ['/c', 'c:\meteor\local\build\programs\public\run.bat']);
Upvotes: 1