1

The thing is : I have one python file
I am executing it using a shell script named run.sh
content of run.sh

python test.py

and in python file I am testing for something and if it is not matching i am exiting using sys.exit(1). I am able to catch this in run.sh using $? But The problem is there is a master shell script ,

master.sh

and run.sh is called from master.sh .
Mater.sh calls multiple shell script from inside. i.e

sh run.sh
sh test.sh

I want to ensure that if run.sh fails , i.e if python file exits with sys.exit(1) then it is catched in master.sh and it doesn't run the next shell script i.e it should then not run the test.sh

2 Answers 2

1

You can do the same thing you did for run.sh, catch the return_code

in master.sh

sh run.sh
if [ $? == 0 ]
then sh test.sh
else
exit 1
fi
Sign up to request clarification or add additional context in comments.

Comments

1

Simply call the script this way: sh run.sh ¦¦ exit 1

1 Comment

is this function similar to ? sh run.sh if [ $? == 0 ] then sh test.sh else exit 1 fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.