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.
Asked
Active
Viewed 124 times
2 Answers
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