我想從python腳本調用命令提示符(&將一些參數傳遞給命令提示符)。從python腳本調用命令提示時的問題
我使用pyqt4開發用戶界面和在用戶界面上我有一個運行按鈕。在選擇運行按鈕時,我想調用一個命令提示符並傳遞一些腳本名稱作爲參數。
self.connect(run_button, SIGNAL('clicked()'), self.runscript) # this is my run button signal and i'm calling the runscript()
def runscript(self):
print 'Inside Run Script'
os.chdir('C:\PerfLocal_PAL')
try:
subprocess.call(['C:\windows\system32\cmd.exe'])
except:
print 'Exception Caused.'
當我點擊運行按鈕時,應用程序死亡,它根本不會調用命令提示符。我嘗試使用os.system以及相同的結果。
另外,我想知道如何將參數傳遞給調用函數?
對此的任何幫助都非常感謝。
感謝,
感謝此部分代碼工作。 – user596922 2011-05-04 06:24:02