Mixing Python And Bash
mwm at mired.org
Tue Nov 9 00:19:44 CET 2004
Tom Purl <tom at tompurl.com> writes:
> 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
> # custom python script
> /usr/bin/python /home/username/Dev/Python/packZODB.py \
> -s"gsgmc.sigma.zettai.net" -b 7
> # next program
> 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.
No, that's not the default in bash.
# custom python script
/usr/bin/python /home/username/Dev/Python/packZODB.py \
-s"gsgmc.sigma.zettai.net" -b 7
if [ $? -eq 0 ]
# next program
[Yes, I know there are shorter solutions. But his command line is long
enough as it is.]
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list