나는 "apt update"를 실행하는 간단한 bash 스크립트를 가지고 있는데, 이렇게 파이썬을 통해 호출하려고 시도했다. 나는 chmod +x update.sh
이 아니지만 실행됩니다.어떻게 파이썬은 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'는 실행할 텍스트가 들어있는 데이터 파일로'update.sh'를 읽는'sh'를 말하고 있습니다. 파이썬이 전혀 관련이 없다면 그건 사실입니다. –
''python foo.py'가'foo.py'를 어떻게 실행하는지와 마찬가지로 실행 가능합니다. –
당신은'update.sh'를 실행하지 않습니다. 'sh'를 실행 중입니다. – user2357112