Need help counting strings with jython - Websphere

This is a discussion on Need help counting strings with jython - Websphere ; Everything I try is failing. I did get a count function to work, but it's taking every single letter in the string and assigning it a number. Wanting to put a limit on how many jvms we have in a ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Need help counting strings with jython

  1. Need help counting strings with jython

    Everything I try is failing. I did get a count function to work, but it's taking every single letter in the string and assigning it a number. Wanting to put a limit on how many jvms we have in a cell.



    ServerList=AdminTask.listServers(' -serverType APPLICATION_SERVER -nodeName crm-unita-61_01')

    print ServerList



    Produces this:



    server1(cells/cell1/nodes/node1/servers/server1|server.xml)

    server2(cells/cell1/nodes/node1/servers/server2|server.xml)

    server3(cells/cell1/nodes/node1/servers/server3|server.xml)

    server4(cells/cell1/nodes/node1/servers/server4|server.xml)

    server5(cells/cell1/nodes/node1/servers/server5|server.xml)

    server6(cells/cell1/nodes/node1/servers/server6|server.xml)



    Anyone know how to count this list with jython? As you can see the serverName is defined twice in the string, in a perfect world I'd be able to use sed to ignore everything in the ().

  2. Re: Need help counting strings with jython

    Got it:



    Count=ServerList.count ( 'server.xml' )

  3. Re: Need help counting strings with jython

    pmaple66@gmail.com wrote:
    > Got it:
    >
    >
    >
    > Count=ServerList.count ( 'server.xml' )


    I think this should also work, and would be more generic:

    Count = len(ServerList.splitlines())

+ Reply to Thread