Şef komutlarımı yürütmek için cmd kullanıyorum, node.js'yi kullanarak bunları nasıl çalıştırırım?node.js işlevinde "chef-apply script.rb" komutunu nasıl çalıştırılır?
PS C:\Users\xyz\chef-repo> chef-apply script.rb
Bu benim kodudur node.js
exports.testscript=function(req,res){
var exec = require('child_process').exec;
console.log("inside function");
var child = exec('chef-apply azurepro.rb' ,{cwd: 'C:\Users\anurag.s\chef-repo'},
function(error, stdout, stderr){
console.log(stdout);
console.log(stderr);
if (error !== null) {
console.log(error);
}
});
//child.stdin.end();
};
kullanarak bu komutu çalıştırmak istiyorum. Bu hatayı alıyorum ve komutum .bat dosyası.
{ [Error: spawn cmd.exe ENOENT]
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn cmd.exe',
path: 'cmd.exe',
cmd: 'cmd.exe /s /c "chef-apply azurepro.rb"' }
[node.js kabuk komut yürütme] 'nin olası kopyası (http://stackoverflow.com/questions/14458508/node-js-shell-command-execution) – StephenKing