当前位置: 动力学知识库 > 问答 > 编程问答 >

linux - executing the bash on the amazon server with a error [Error: spawn EACCES], the bash is in right path

问题描述:

I am using the gith to build a webhook server on the amazon server to automate the deployment. When I updated my repository, the gith server can receive the update, then I want to execute the bash.

The bash file is on the path of /home/ubuntu/node/githook/hook.sh, console.log(__dirname+'/hook.sh'); output the right path, but when using the execFile to execute the path, it gave a error

error { [Error: spawn EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }

The code is above, but don't know why executing the code gave me such error.

var gith = require('gith').create( 8080 );

var execFile = require('child_process').execFile;

gith({

repo: 'heroku/node-js-sample'

}).on( 'all', function( payload ) {

if( payload.branch === 'master' )

{

//console.log('all',payload );

console.log(__dirname+'/hook.sh');

execFile(__dirname+'/hook.sh', function(error, stdout, stderr) {

// Log success in some manner

if(error) console.log("error",error);

else console.log( 'exec complete',stdout );

});

}

});

网友答案:

You have to make your bash script executable. Use this :

chmod +x hook.sh
分享给朋友:
您可能感兴趣的文章:
随机阅读: