Search code examples
webspherejythonwsadmin

wsadmin printing results with a single character per line


I'm trying to use the output from some wsadmin commands to use in other commands, however, when I loop through the output, it seems to print a single character per line, which blows up my other commands. What do I need to add to make this not print a single character per line.

cell_name = AdminControl.getCell()
# Get the DMGR Complete Object Name
dmgr_object_name =  AdminControl.completeObjectName('WebSphere:name=DeploymentManager,type=DeploymentManager,mbeanIdentifier=DeploymentManager,*')
# Get the full Application Manager string. 
appManager = AdminControl.queryNames('cell=' + cell_name + ',type=ApplicationManager,*')

for jvm in appManager :
  print( jvm )

Solution

  • The Answer is to import the Java lineseparator

    # get line separator
    import  java.lang.System  as sys
    lineSeparator = sys.getProperty('line.separator')
    # Get the Cell Name
    cell_name = AdminControl.getCell()
    # Get the DMGR Complete Object Name
    dmgr_object_name =  AdminControl.completeObjectName('WebSphere:name=DeploymentManager,type=DeploymentManager,mbeanIdentifier=DeploymentManager,*')
    # Get the full Application Manager string. 
    appManager = AdminControl.queryNames('cell=' + cell_name + ',type=ApplicationManager,*').split(lineSeparator)
    

    This then allows the results to be split properly.