Mixing Python And Bash

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Tue Nov 9 10:37:59 CET 2004

Tom Purl a écrit :
> 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
> I don't want the second program to run if the first program fails.  Isn't
> that the default in bash?  If someone could please point me in the right
> direction regarding this problem, I would really appreciate it.
> Thanks in advance!
> Tom Purl

If you only have 2 programs (or few programs) you can use :

prog1 && prog2

Then prog2 will only be launched if prog1 succeeded ...


More information about the Python-list mailing list