Execute bash command in Node.js and get exit code

后端 未结 4 985
忘了有多久
忘了有多久 2020-12-13 02:02

I can run a bash command in node.js like so:

var sys = require(\'sys\')
var exec = require(\'child_process\').exec;

function puts(error, stdout, stderr) { s         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 02:55

    In node documentation i found this information for the callback function:

    On success, error will be null. On error, error will be an instance of Error. The error.code property will be the exit code of the child process while error.signal will be set to the signal that terminated the process. Any exit code other than 0 is considered to be an error.

提交回复
热议问题