Search code examples
pythonlinuxpopenpython-3.3

Running .sh file from Python script?


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.


Solution

  • 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.