+

Search Tips   |   Advanced Search

Starting listener ports using scripting

These steps demonstrate how to start a listener port on an application server using scripting.

Perform the following steps to start a listener port on an application server. The following example returns a list of listener port MBeans:


Tasks

  1. Identify the listener port MBeans for the application server and assign it to the lPorts variable.

    • Jacl:
      set lPorts [$AdminControl queryNames type=ListenerPort,
      cell=mycell,node=mynode,process=server1,*]
      
    • Jython:
      lPorts = AdminControl.queryNames('type=ListenerPort,
      cell=mycell,node=mynode,process=server1,*')
      print lPorts
      

    Example output:

    WebSphere:cell=mycell,name=ListenerPort,mbeanIdentifier=server.xml#
    ListenerPort_1,type=ListenerPort,node=mynode,process=server1
    WebSphere:cell=mycell,name=listenerPort,mbeanIdentifier=ListenerPort,
    type=server.xml#ListenerPort_2,node=mynode,process=server1
    

  2. Start the listener port if it is not started. For example:

    • Jacl:
      foreach lPort $lPorts {
           set state [$AdminControl getAttribute $lport started]
           if {$state == "false"} {
              $AdminControl invoke $lPort start
           }
        }
      
    • Jython:
      # get line separator 
      import  java
      lineSeparator = java.lang.System.getProperty('line.separator')
      
      lPortsArray = lPorts.split(lineSeparator)
      for lPort in lPortsArray:
      	state = AdminControl.getAttribute(lPort, 'started')
      	if state == 'false':
      		AdminControl.invoke(lPort, 'start')
      

    These pieces of Jacl and Jython code loop through the listener port MBeans. For each listener port MBean, get the attribute value for the started attribute. If the attribute value is set to false, then start the listener port by invoking the start operation on the Bean.

  • wsadmin AdminControl
  • Start the wsadmin scripting client
  • Commands for the AdminControl object