Mixing Python And Bash
Leif K-Brooks
eurleif at ecritters.biz
Mon Nov 8 18:22:05 EST 2004
Tom Purl wrote:
> I just wrote a Python script that is going to be called from bash script.
> If the Python script fails, I want the bash script to also stop running.
> Unfortunately, I can't seem to get that to work. Here's the script so
> far:
>
> # custom python script
> /usr/bin/python /home/username/Dev/Python/packZODB.py \
> -s"gsgmc.sigma.zettai.net" -b 7
>
> # next program
> /usr/bin/someOtherProgram
Have your Python script return a non-zero return code (e.g. sys.exit(1))
when it fails and then have your shell script check for that:
# custom python script
/usr/bin/python /home/username/Dev/Python/packZODB.py \
-s"gsgmc.sigma.zettai.net" -b 7
if [ $? -ne 0 ]; then
exit 1
fi
# next program
/usr/bin/someOtherProgram
More information about the Python-list
mailing list