user449355 user449355 - 6 months ago 13
Python Question

How to call a shell script from python code?

how to call a shell script from python code?

Answer

The subprocess module will help you out.

Here is a decent tutorial.

Blatantly trivial example:

>>> import subprocess
>>> subprocess.call(['./test.sh']) # Thanks @Jim Dennis for suggesting the []
0 
>>> 

Where test.sh is a simple shell script and 0 is its return value for this run.

Comments