Spherus.biz Home          

Running the Scripts

This section deals with the execution of the Jython scripts created in this tutorial. The WebSphere Application Server has a scripting interface in the form of wsadmin. This tool can be invoked in an interactive mode, single command mode or the execution of a script.

The wsadmin.sh or wsadmin.bat tool can be found in the >PROFILE_HOME</bin directory. For the purposes of this tutorial we will assume a Linux or Unix distribution which makes use of wsadmin.sh. For a Windows distribution the command to use will be wsadmin.bat. Both distributions have the same command line parameters and the same functionality. The Jython scripts created can be used on either distribution without modification.

1. Interactive Mode

The easiest way to launch wsadmin.sh is in the interactive mode, however this is probably the most difficult to use.

Use the following command to Launch wsadmin:

<PROFILE_HOME>/bin/wsadmin.sh

Assuming we have a running instance of the server defined in the profile, wsadmin should connect to this server. We can, however, control which server to connect to and what protocol to use.

To connect to a specific server use the following command:

<PROFILE_HOME>/bin/wsadmin.sh -conntype SOAP -hostname <WAS_HOST> -port <PORT_NUMBER>

Example:

<PROFILE_HOME>/bin/wsadmin.sh -conntype SOAP -hostname was.spherus.biz -port 8879

There are a number of options that can be passed to wsadmin. These are listed here wsadmin.sh Command Line Options

In order to exit wsadmin.sh from interactive mode, type exit

wsadmin> exit

2. Single Command Mode

In order to execute a single command use the -c option with the command included.

<PROFILE_HOME>/bin/wsadmin.sh -lang jython -c <COMAND>

Example:

<PROFILE_HOME>/bin/wsadmin.sh -lang jython -c AdminConfig.listTemplates('JDBCProvider', 'DB2 Universal JDBC Driver Provider Only (XA)')

3. Script mode

In order to execute a script we use the following command:

<PROFILE_HOME>/bin/wsadmin.sh -f <SCRIPT_FILE> -lang jython

We need to tell wsadmin to use the jython language as it makes use of JACL by default.

Example:

<PROFILE_HOME>/bin/wsadmin.sh -lang jython -f listServers.py

4. Loading a Profile of Functions

If we wish to load a script file of functions into memory, but not execute that script, we can use the -profile option. This will load the script file into memory and make the functions available for use either on the command line or within a script. Throughout this tutorial we will be building a library of functions to perform configuration tasks. These will be loaded as profile scripts. This will be covered in more details later in the tutorials.

The command to load a script as a profile is as follows:

<PROFILE_HOME>/bin/wsadmin.sh -lang jython -profile functions.py
    

Continue with the basics.