Network Deployment (Distributed operating systems), v8.0 > Scripting the application serving environment (wsadmin) > Welcome to scripting for web services


Start wsadmin.sh


Overview

wsadmin.sh only supports the Jython and Jacl scripting languages.

For jython scripts, to ensure all of required JAR files are set, include the system property...

For example...

To invoke WAS functions from different WAS classes that are packaged in .jar files other than runtime.jar and admin.jar, you can include multiple jar files in the path specified for the jython.package.path system property, and separate them with a semicolon (;).

To invoke WAS functions in a jython script using ws_ant, you can create a .prop file text file, and include the following line in this file:

Then include the property file in the ant script xml file. For example:

    <taskdef name="wsadmin"
                classname="com.ibm.websphere.ant.tasks.WsAdmin"/>

    <target name="main" >

        <wsadmin conntype="NONE"
                 lang="jython"
                 failonerror="true"
                 properties="/tmp/jython.prop"
                 script="/home/wpadmin/scripts/jython/configure.py">

        </wsadmin>
    </target>

wsadmin.sh cannot connect to an application server, dmgr, administrative agent, or job manager that runs a product version which is older than the version of wsadmin.sh. For example, a v6.x wsadmin client cannot connect to a v5.x application server. However, a v5.x wsadmin client can connect to a v6.x application server. This limitation exists because new functionality is added to wsadmin.sh in each product release. We cannot use new command functionality on application servers running previous product versions.

The wsadmin tool operates at the dmgr node level in a mixed-cell environment. Do not run wsadmin at the application server node level to ensure that all command functionality is available.

To use a non-default profile, specify the parameter...


Run wsadmin.sh

  1. In a flexible management environment, determine whether to connect to a base application server, admin agent, or job manager process.

    • Connect to the admin agent process.

      Connect the wsadmin tool to the admin agent to configure, manage, and administer servers. If you do not specify connection options, the wsadmin tool automatically connects to the admin agent process.

        wsadmin -lang jython

    • Connect to a base application server process.

      Connect the wsadmin tool to a base application server to manage settings for a specific server of interest. Use this connection type when connecting to a node that contains one server and is registered with the administrative agent. Use the following command to connect to a base application server:

        wsadmin -conntype SOAP [-port 4213] -lang jython

    • Connect to the job manager process.

      Connect the wsadmin tool to the job manager to submit, monitor, and manage administrative jobs. Use the following command to connect to the job manager:

        wsadmin -profileName myJobManager -lang jython

  2. Review additional connection options for wsadmin.sh.

    We can start the wsadmin scripting client in several different ways.

    To specify the method for running scripts, perform one of the following wsadmin tool options:

    Run scripting commands interactively

    Run wsadmin with an option other than -f or -c or without an option. The wsadmin tool starts and displays an interactive shell with a wsadmin prompt. From the wsadmin prompt, enter any Jacl or Jython command. We can also invoke commands using the AdminControl, AdminApp, AdminConfig, AdminTask, or Help wsadmin objects.

    To leave an interactive scripting session, use the quit or exit commands. These commands do not take any arguments.

    The following examples launch wsadmin.sh:

    • Launch wsadmin.sh using Jython:

      (AIX) (Solaris)

        wsadmin.sh -lang jython
      (Windows)

        wsadmin.bat -lang jython

    • Launch wsadmin.sh using Jython when security is enabled:

      (AIX) (Solaris)

        wsadmin.sh -lang jython -user wsadmin -password wsadmin
      (Windows)

        wsadmin.bat -lang jython -user wsadmin -password wsadmin

    • Launch wsadmin.sh using Jacl with no options:

      (AIX) (Solaris)

        wsadmin.sh -lang jacl
      (Windows)

        wsadmin.bat -lang jacl

    Run scripting commands as individual commands

    Run wsadmin.sh with the -c option.

    (AIX) (Solaris) If you invoke a command that includes a dollar sign character ($) using the wsadmin -c option, the command line attempts to substitute a variable.

    To avoid this problem, escape the dollar sign character with a backslash character (\). For example: wsadmin -c "\$AdminApp install ...".

    The following examples run commands individually:

    • Run the list command for the AdminApp object using Jython:

      (AIX) (Solaris)

        wsadmin.sh -lang jython -c 'AdminApp.list()'
      (Windows)

        wsadmin -lang jython -c "AdminApp.list()"

    • Run the list command for the AdminApp object using Jacl:

      (AIX) (Solaris)

        wsadmin.sh -c "\$AdminApp list"
      or

        wsadmin.sh -c '$AdminApp list'

      (Windows)

        wsadmin -c "$AdminApp list"

    Run scripting commands in a script

    Run wsadmin.sh with the -f option, and place the commands to run into the file.

    The following examples run scripts:

    • Run the a1.py script using Jython:

      (AIX) (Solaris)

        wsadmin.sh -lang jython -f al.py
      (Windows)

        wsadmin -lang jython -f al.py

      where the a1.py file contains the following commands:

        apps = AdminApp.list() print apps

    Run scripting commands in a profile script

    A profile script is a script that runs before the main script, or before entering interactive mode. We can use profile scripts to set up a scripting environment that is customized for the user or the installation.

    By default, the following profile script files might be configured for the com.ibm.ws.scripting.profiles profiles property in the WAS_HOME/properties/wsadmin.properties file:

    • WAS_HOME/bin/securityProcs.jacl
    • WAS_HOME/bin/LTPA_LDAPSecurityProcs.jacl

    By default, these files are in ASCII. If you use the profile.encoding option to run EBCDIC encoded profile script files, change the encoding of the files to EBCDIC.

    To run scripting commands in a profile script, run wsadmin.sh with the -profile option, and include the commands to run into the profile script.

    To customize the script environment, specify one or more profile scripts to run.

    Do not use parenthesis in node names when creating profiles.

    The following examples run profile scripts:

    • Run the a1prof.py script using Jython:

      (AIX) (Solaris)

        wsadmin.sh -lang jython -profile alprof.py
      (Windows)

        wsadmin.bat -lang jython -profile alprof.py

      where the a1prof.py file contains the following commands:

        apps = AdminApp.list()
        print "Applications currently installed:\n " + apps

    • Run the a1prof.py script using Jacl:

      (AIX) (Solaris)

        wsadmin.sh -profile alprof.jacl
      (Windows)

        wsadmin.bat -profile alprof.jacl

      where the a1prof.py file contains the following commands:

        set apps [$AdminApp list]
        puts "Applications currently installed:\n$apps"


Results

The wsadmin returns the following output when it establishes a connection to the server process:

Jython example output:

Jacl example output:


wsadmin scripting tool

+

Search Tips   |   Advanced Search