WAS v8.5 > Script the application serving environment (wsadmin) > Manage servers and nodes with scripting

Start listener ports using scripting

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


Before beginning

Before starting this task, wsadmin must be running. See the topic about starting the wsadmin scripting client using wsadmin.sh for more information. Perform the following steps to start a listener port on an application server. The following example returns a list of listener port MBeans:

  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 MBean.


Related


Use the wsadmin scripting AdminControl object for scripted administration
Start the wsadmin scripting client using wsadmin.sh
:

Commands for the AdminControl object using wsadmin.sh


+

Search Tips   |   Advanced Search