[ACCEPTED]-Inside python code, how do I run a .sh script?-shell
Accepted answer
Using subprocess.call is the easiest way. It will not return 3 until the executed program has terminated. Have 2 a look at the other methods of the subprocess module if you 1 need different behaviour.
import os
os.system('./script.sh')
python script won't stop until sh is finished
0
You can use os.system
or subprocess.Popen
or subprocess.call
but when using subprocess 4 methods make sure you use shell=True
. And executing 3 it via system call in all these methods 2 is blocking. The python script will complete 1 and then go the next step.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.