簡體   English   中英

將參數從Python腳本發送到批處理腳本

[英]Sending arguments from a Python script to a batch script

我正在嘗試將參數從Python腳本發送到批處理腳本,但是批處理文件始終失敗。

這是用Python腳本編寫的:

cond = 'a'
sp3 = subprocess.Popen([os.path.join(lua_caller_pth[:indx], 'lua_caller1.bat'), cond])

cond = 'b'
sp4 = subprocess.Popen([os.path.join(lua_caller_pth[:indx], 'lua_caller1.bat'), cond])

這是批處理腳本:

if %cond% == "a" (
    %CYGWINPATH%\bash -l -c "cd $START_DIR \ && cd .. \ && cd Debug \ && ./iv4_console.exe ../embedded/LUA/analysis/verbose-udp-toxml.lua &>../Object_Detection_Test_Script/xmllog1 \ && exit; bash";
)
if %cond% == "b" (
    %CYGWINPATH%\bash -l -c "cd $START_DIR \ && cd .. \ && cd Debug \ && ./iv4_console.exe ../embedded/LUA/analysis/verbose-udp-toxml.lua &>../Object_Detection_Test_Script/xmllog2 \ && exit; bash";
)

在您的腳本中

%cond% 

評估尚未由python程序設置的環境varibale cond

您需要從批處理中評估命令行參數,而不是評估環境。 有關如何執行此操作的更多信息,請參見獲取Windows批處理腳本(.bat)中傳遞的參數的列表

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM