简体   繁体   English

将参数从Python脚本发送到批处理脚本

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

I'm trying to send arguments from a Python script to a batch script, but the batch file keeps failing. 我正在尝试将参数从Python脚本发送到批处理脚本,但是批处理文件始终失败。

This is what is written in the Python script: 这是用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])

And this is the batch script: 这是批处理脚本:

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";
)

In your script 在您的脚本中

%cond% 

evaluates the environment varibale cond , that has not been set by your python program. 评估尚未由python程序设置的环境varibale cond

You need to evaluate the command line argument from your batch instead of evaluting the environment. 您需要从批处理中评估命令行参数,而不是评估环境。 See Get list of passed arguments in Windows batch script (.bat) for more information how to do that. 有关如何执行此操作的更多信息,请参见获取Windows批处理脚本(.bat)中传递的参数的列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM