wsadmin.sh

 


Overview

The WAS wsadmin.sh tool provides the ability to execute scripts against a WAS V5.0 installation, providing application management, configuration, operational control, communication with MBeans.

The wsadmin tool uses BSF as a framework, and supports the JACL for scripting.

 


JACL syntax

There are two ways to construct a JACL command, with curly braces, or with brackets. Here is an example using braces:

$AdminConfig create ListenerPort $mls {{destinationJNDIName prefix/buyer/jms/ErrorBizDocQueue}{connectionFactoryJNDIName prefix/buyer/jms/XaQueueConnectionFactory} {maxMessages 1}{maxRetries 0}{maxSessions 5}{name ErrorBizDocMessageEJBPort}{stateManagement {{initialState START}}}}

Here is an example using brackets:

$AdminConfig create ListenerPort $mls [list [list destinationJNDIName buyer/jms/ErrorBizDocQueue] [list connectionFactoryJNDIName buyer/jms/XaQueueConnectionFactory] [list maxMessages 1] [list maxRetries 0] [list maxSessions 5] [list name ErrorBizDocMessageEJBPort] [list stateManagement [list [list initialState START] ] ] ]

These code snippets are functionally equivalent.

The advantage of using brackets is you can insert variables, so we could write the above code as:

set destJNDIName buyer/jms/ErrorBizDocQueue
set connectJNDIName "buyer/jms/XaQueueConnectionFactory

$AdminConfig create ListenerPort $mls [list [list destinationJNDIName $destJNDIName] [list connectionFactoryJNDIName $connectJNDIName] [list maxMessages 1] [list maxRetries 0] [list maxSessions 5] [list name ErrorBizDocMessageEJBPort] [list stateManagement [list [list initialState START] ] ] ]

To do a mass search and replace in vi, you can run:

:%s/%s/{/\[list /g
:%s/\}/] /g

 

wsadmin.sh Syntax

The command line invocation syntax for the wsadmin scripting client follows:

wsadmin [ -h(help) ] 
        [ -? ] 
        [ -c commands ] 
        [ -p properties_file_name ] 
        [ -profile profile_script_name ] 
        [ -f script_file_name ] 
        [ -javaoption java_option ]
        [ -lang language ] 
        [ -wsadmin_classpath classpath ]
        [ -conntype SOAP [ -host host_name ] 
                         [ -port port_number ] 
                         [ -user  userid ] 
                         [ -password password ] | 
                     RMI [ -host host_name ] 
                         [ -port port_number ] 
                         [ -user userid ] 
                         [-password password ] |
                    NONE ]
        [ script parameters ] 

variable contains the number of parameters. The argv variable contains their contents

 

Options

 

-c command

Designates a single command to execute.

Multiple -c options can exist on the command line. They run in the order that you supply them.

 

-f scriptname

Designates a script to execute.

Only one -f option can exist on the command line.

 

-javaoption

Specifies a valid Java standard or non-standard option.

Multiple -javaoption options can exist on the command line.

 

-lang

Specifies the language of the script file, command, or interactive shell. In WAS V5.0, Jacl is the only supported scripting language.

This argument is required if not determined from the script file name. It overrides language determinations that are based on a script file name, or the com.ibm.ws.scripting.defaultLang property. There is no default value for the -lang argument. If the command line or the property does not supply the script language, and the wsadmin tool cannot determine it, an error message generates.

 

-p

Specifies a properties file.

The file listed after -p, represents a Java properties file that the scripting process reads. Three levels of default properties files load before the properties file you specify on the command line. The first level is the installation default:

$WAS_HOME/properties/wsadmin.properties

The second level is the user default:

$HOME/wsadmin.properties

The third level is the properties file pointed to by the environment variable WSADMIN_PROPERTIES.

Multiple -p options can exist on the command line. They invoke in the order that you supply them.

 

-profile

Specifies a profile script.

The profile script runs before other commands, or scripts. If you specify -c , the profile executes before it invokes this command. If you specify -f , the profile executes before it runs the script. In interactive mode, you can use the profile to perform any standard initialization that you want. You can specify multiple -profile options on the command line, and they invoke in the order that you supply them.

 

-?

Provides syntax help.

 

-help

Provides syntax help.

 

-conntype

Specifies the type of connection to use.

This argument consists of a string that determines the type, for example, SOAP, and the options that are specific to that connection type. Possible types include: SOAP , RMI , and NONE .

The options for -conntype include: host , port , user , and password .

Use the -conntype NONE option to run in local mode. The result is that wsadmin.sh is not connected to a running server.

 

-wsadmin_classpath

Use this option to make additional classes available to your scripting process.

Follow this option with a classpath string. For example:

/some/directory/Myjar.jar;/some/other/directory/yourdir.jar
The classpath is then added to the classloader for the scripting process.

You can also specify this option in a properties file that is used by the wsadmin tool. The property is com.ibm.ws.scripting.classpath . If you specify -wsadmin_classpath on the command line, the value of this property overrides any value specified in a properties file. The classpath property and the command line options are not concatenated.

 

Examples

In the following syntax examples, mymachine is the name of the host in the wsadmin.properties file, specified by com.ibm.ws.scripting.port :

 

SOAP connection to the local host

Use the options defined in the wsadmin.properties file.

 

SOAP connection to the mymachine host

wsadmin -f test1.jacl -profile setup.jacl -conntype SOAP -host mymachine

 

Initial and maximum Java heap size

wsadmin -javaoption -Xms128m -javaoption -Xmx256m -f test.jacl

 

RMI connection with security

wsadmin -connector RMI -userid userid -password password

 

Local mode of operation to perform a single command

wsadmin -conntype NONE -c "$AdminApp uninstall app"


wsadmin tool performance tips

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.