我嘗試從命令中運行帶有ini配置文件的python腳本的Windows命令行應用程序,我懷疑它沒有在執行時傳遞。使用ini文件參數從python運行windows命令行程序
該命令是c:\ BLScan \ blscan.exe test.ini。
ini文件是應用程序需要知道要掃描的參數的配置文件。
這是使用
import subprocess
from subprocess import Popen, PIPE
cmd = '/blscan/blscan test.ini'
p = Popen(cmd , stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
print "Return code: ", p.returncode
print out.rstrip(), err.rstrip()
當我使用subprocess.popen調用應用程序它不看要讀ini文件腳本IM。設備線是一個指示器,表明調音器沒有從ini文件中識別出來,因此程序正在下降到默認調諧器。
Return code: 0
BLScan ver.1.1.0.1091-commited
Config name: .\test.ini
Device 0: TBS 6925 DVBS/S2 Tuner
Device number: Total Scan Time = 0.000s
Transponders not found !
>>>
這是從dos shell運行時的樣子。
C:\BLScan>blscan test.ini
BLScan ver.1.1.0.1091-commited
Config name: .\test.ini
Scan interval 0
From 3400 to 3430 Mhz, Step 5 Mhz, Horizontal, Minimal SR 1000 KS, Maximal SR 10
0000 KS
3400 Mhz ...
3405 Mhz ...
3410 Mhz ...
任何意見將理解
感謝您花時間解決問題和解決方案。現在正常工作:) – satraver 2013-05-04 21:36:41