Reputation: 43
I am having trouble running a .sh
script in Oracle Linux 6.8 using a python script I have developed. I've developed these scripts in Windows OS and they run without a problem, now I am trying to modify these scripts to run them on Linux but I am having problems since I am not familiar with Linux OS.
I run a .bat
file in Windows using the Popen
command in python, for example:
p = Popen("StartScript.bat", cwd=r"My path")
Where StartScript.bat
is the .bat
file, and My Path
is the path where the .bat
file is located. This works very good in Windows OS, but how do I do the same for Linux OS, if I want to run a StartScript.sh
file.
Upvotes: 4
Views: 71096
Reputation: 76
use this lines:
import os
os.popen('sh command')
for example
import os
os.popen('sh /home/oracle/scripts/start.sh')
enjoy
Upvotes: 4
Reputation: 1143
execute a shell-script from Python subprocess
How to execute a shell script through python
Please take a look at these two threads. Hope it helps.
Upvotes: 5