how to stop multiple python script running if any script has error
<p>I have python script (installer.py) which runs multiple python and shell programs:</p>

<pre><code>print "Going to run Script1"

os.system("python script1.py")

print "Going to run Script2"

os.system("python script2.py")
</code></pre>

<p>But I found that even if script1.py is not run because of its error, it simply moves on to run script2.py.</p>

<p>How to stop the script (installer.py) at the time of script1.py itself..</p>

<p><code>os.system</code> will return the exit status of the system call. Just check to see if your command executed correctly.</p>

<pre><code>ret = os.system('python script1.py')
if ret != 0:
    # call failed
    raise Exception("System call failed with error code %d" % ret)


ret = os.system('python script2.py')
if ret != 0:
    # call failed
    raise Exception("System call failed with error code %d" % ret)
</code></pre>

python linux