2017-04-08 8 views
0

変数名と値をjythonスクリプトからバッチファイルに渡したいと思います。また、どのように私はバッチファイルでそれにアクセスすることができます。変数名と値をjythonからバッチファイルに渡す方法

私の場合、 "bootstrapport"と "defaulthostport"の名前と値をバッチファイルDeploy.batに渡したいと思います。バッチファイルにテキストファイルからvaraible値を読み取ってテキストファイルを削除し、テキストファイルにJythonの結果をプリント

このprobemを解決

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

バッチファイル

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 
関連する問題