0

I had a script written in node.js which returns the appropriate exit code, either 0 for success and 1 for error. I am running this script in a shell script and need to compare the exit code to perform a few more operations, by using an if else block. Any suggestions how I can do that. I know we can use $? to get the exit code in shell. Thanks in advance.

user1386101
  • 1,945
  • 1
  • 14
  • 21

2 Answers2

0

See exec(), particularly the return_var argument.

Apologies, I thought I saw a PHP tag.

CAMason
  • 1,122
  • 7
  • 13
0

Exit Shell Script Based on Process Exit Code

Thats the solution.

rc=$?

if [[ $rc != 0 ]] ; then exit 2 fi

Community
  • 1
  • 1
user1386101
  • 1,945
  • 1
  • 14
  • 21