繁体   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