我想将变量名和值从jython脚本传递到批处理文件。另外,我如何在批处理文件中访问它。
在我的情况下,我想将“bootstrapport”和“defaulthostport”的可变名称和值传递给批处理文件Deploy.bat。
ports.jy
-
servers = AdminConfig.list( 'ServerEntry' ).splitlines() for server
in servers : print '\n' print "Server Name : " +
server[0:server.find('(')] print "=" *30 NamedEndPoints =
AdminConfig.list( "NamedEndPoint" , server).splitlines()
for namedEndPoint in NamedEndPoints: endPointName =
AdminConfig.showAttribute(namedEndPoint, "endPointName" )
if endPointName == "BOOTSTRAP_ADDRESS":
bootstrapendPoint = AdminConfig.showAttribute(namedEndPoint, "endPoint" )
host = AdminConfig.showAttribute(bootstrapendPoint, "host" )
bootstrapport = AdminConfig.showAttribute(bootstrapendPoint, "port" )
print "Endpoint Name : " + endPointName + " Host : " + host + " port : " +
bootstrapport
elif endPointName == "WC_defaulthost":
defaulthostendPoint = AdminConfig.showAttribute(namedEndPoint,"endPoint" )
host = AdminConfig.showAttribute(defaulthostendPoint,"host" )
defaulthostport =AdminConfig.showAttribute(defaulthostendPoint, "port" )
print "Endpoint Name : " + endPointName + " Host : " + host + " port : " +
defaulthostport
========================================================================
答案 0 :(得分:0)
解决了这个问题
在文本文件中打印jython结果,然后从文本文件中读取可变值到批处理文件,然后删除文本文件。
批量文件
for /f "delims=" %%x in (Output) do set EMULATOR_PORT=%%x
echo EMULATOR_PORT %EMULATOR_PORT%
set "BOOTSTRAP_PORT="
for /f "skip=5 delims=" %%a in (Output) do if not defined BOOTSTRAP_PORT set BOOTSTRAP_PORT=%%a
del Output