【问题标题】:How to pass variable name and value from jython to batch file如何将变量名和值从 jython 传递到批处理文件
【发布时间】:2017-04-08 16:42:21
【问题描述】:

我想将变量名和值从 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

        ========================================================================

【问题讨论】:

    标签: python batch-file websphere jython


    【解决方案1】:

    解决了这个问题

    在文本文件中打印 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-08
      • 2012-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      相关资源
      最近更新 更多