This discussion is archived
3 Replies Latest reply: Mar 29, 2013 5:01 AM by 649018 RSS

How to get the return values of WLST command output

Aacc Newbie
Currently Being Moderated
Could someone give a sample code how to get the return values of a WLST command from script?
for example, listApplications() output a list of applications. how do I consume this list in a script? is it possible to assign the returned list to a collection type variable?
I did not mention what script language to use but looks like the easiest way of doing this is using Jython since wlst is written in Jython. please help me to understand if other option is better too.
  • 1. Re: How to get the return values of WLST command output
    Pierluigi Vernetto Pro
    Currently Being Moderated
    the simplest solution is to write the list to a file. easy does it.
  • 2. Re: How to get the return values of WLST command output
    997468 Explorer
    Currently Being Moderated
    Hi,

    You could try something like below where I am retrieving list of server names from WLST command and then opening the list for operation in a for loop.

    serverNames = getRunningServerNames()
    for name in serverNames:
    cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName())


    see above list retrieved is stored in variable "serverNames" as list and then used in for loop.

    Thanks,
    Ranjan
  • 3. Re: How to get the return values of WLST command output
    649018 Explorer
    Currently Being Moderated
    It depends upon the command. listApplications() does not appear to return a value, so you'll have to interact with the runtime MBeans directly, e.g.,

    wls:/mydomain/serverConfig> cd serverRuntime:/

    wls:/mydomain/serverRuntime> apps=cmo.getApplicationRuntimes()

    wls:/mydomain/serverRuntime> print apps
    array(weblogic.management.runtime.ApplicationRuntimeMBean,[[MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=mejb,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=bea_wls_deployment_internal,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=bea_wls_diagnostics,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=bea_wls_management_internal2,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=bea_wls_internal,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=stressapp,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=wstestclient,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=consoleapp,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=wls-wsat,Type=ApplicationRuntime, [MBeanServerInvocationHandler]com.bea:ServerRuntime=myserver,Name=bea_wls9_async_response,Type=ApplicationRuntime])

    From there you can interact with the elements in the "apps" array, which are instances of ApplicationRuntimeMBean.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points