我有一个简单的运行“apt更新”的bash脚本我试图通过Python这样调用它。它运行虽然我没有chmod +x update.sh
它。python如何让bash脚本在不可执行的情况下运行?
def updateUsingBash(self):
p = QtCore.QProcess()
p.finished.connect(self.onFinished)
p.start('sh', ['update.sh'])
p.waitForFinished(-1)
def onFinished(self, exit_code, exit_status):
print "script finished with exit code :", exit_code
'sh update.sh'告诉'sh'读取'update.sh'作为包含要运行的文本的数据文件。没有Python在任何地方参与都是如此。 –
这与'python foo.py'运行'foo.py'的方式是一样的,而且它也不可执行。 –
你没有执行'update.sh'。你正在执行'sh'。 – user2357112