我在使用我开发的 python 脚本在 Oracle Linux 6.8 中运行 .sh
脚本时遇到问题。我在 Windows 操作系统中开发了这些脚本并且它们运行没有问题,现在我试图修改这些脚本以在 Linux 上运行它们但是我遇到了问题,因为我不熟悉 Linux 操作系统。
我在 Windows 中使用 Popen
命令在 python 中运行一个 .bat
文件,例如:
p = Popen("StartScript.bat", cwd=r"我的路径")
其中StartScript.bat
为.bat
文件,My Path
为.bat
所在路径> 文件位于。这在 Windows 操作系统中非常有效,但如果我想运行 StartScript.sh
文件,我该如何在 Linux 操作系统中执行同样的操作。
最佳答案
execute a shell-script from Python subprocess
How to execute a shell script through python
请看一下这两个线程。希望对您有所帮助。
关于python - 从 Python 脚本运行 .sh 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42900259/