2017-04-08 74 views
0

我想将变量名和值从jython脚本传递到批处理文件。另外,我如何在批处理文件中访问它。如何将变量名和值从jython传递到批处理文件

在我的情况下,我想将“bootstrapport”和“defaulthostport”的varname名称和值传递给批处理文件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

解决了这个probem

印刷在文本文件中的Jython的结果,那么读取文本文件批处理文件varaible值,然后删除该文本文件。

批处理文件

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 
相关问题