Run wsadmin.sh
Overview
The wsadmin.sh utility provides the ability to execute scripts for managing a WAS installation. wsadmin.sh uses the Bean Scripting Framework, which supports a variety of scripting languages includng Jacl and Jython.
Syntax
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] [-conntype RMI [-host host_name] [-port port_number] [-user userid] [-password password] | NONE ] [script parameters]Where script parameters represent any arguments other than the ones listed previously. The argc variable contains their number, and 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. The possible languages include: Jacl and Jython. The options for the -lang argument include: jacl and jython. 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, wsadmin.properties, located in the WAS properties directory. The second level is the user default, wsadmin.properties, located in your home directory. 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: SOAP, RMI, and NONE.
Use the -conntype NONE option to run in local mode. The result is that the scripting client 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 class path string. For example
/path/to/Myjar.jar;/path/to/yourdir.jar.The class path is then added to the class loader 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 class path property and the command-line options are not concatenated.
Example
In the following syntax examples, mymachine is the name of the host in the wsadmin.properties file, specified by the com.ibm.ws.scripting.port property...
SOAP connection local host Use the options defined in the wsadmin.properties file.
SOAP connection mymachine Using Jacl wsadmin -f test1.jacl \ -profile setup.jacl \ -conntype SOAP \ -host mymachineUsing Jython
wsadmin -lang jython \ -f test1.py \ -profile setup.py \ -conntype SOAP \ -host mymachine
Initial and maximum Java heap size Using Jacl wsadmin -javaoption \ -Xms128m \ -javaoption \ -Xmx256m \ -f test.jaclUsing Jython
wsadmin -lang jython \ -javaoption \ -Xms128m \ -javaoption \ -Xmx256m \ -f test.py
RMI connection with security Using Jacl wsadmin -connector RMI \ -port rmiportnumber \ -userid userid \ -password passwordUsing Jython
wsadmin -lang jython \ -connector RMI \ -port rmiportnumber \ -userid userid \ -password password
Local mode. Single command Using Jacl wsadmin -conntype NONE \ -c "$AdminApp uninstall app"Using Jython
wsadmin -lang jython \ -conntype NONE \ -c "AdminApp.uninstall('app')"
Interactively
Run scripting commands interactively by executing wsadmin.sh with an option other than -f or -c. For example, using Jacl...
wsadmin.shWASX7209I: Connected to process server on node node using SOAP connector; The type of process is: UnManagedProcess WASX7029I: For help, enter: "$Help help" wsadmin>$AdminApp list adminconsole DefaultApplication ivtApp wsadmin>exit...using Jython...
wsadmin.sh -lang jythonType 'quit' or 'exit' to leave an interactive session.
With Individual commands
Run scripting commands as individual commands by using the -c option. For example, using Jaclwsadmin.sh -c '$AdminApp list'...using Jython...
wsadmin.sh -lang jython -c "AdminApp.list()"
Using a script file
Run scripting commands in a script by using the -f option and placing your commands in a file. For example, using Jacl...
...where filename.jacl contains...wsadmin -f filename.jaclset apps [$AdminApp list] puts $apps...using Jython
...where the filename.py file contains...wsadmin -lang jython -f filename.pyapps = AdminApp.list() print apps
Using a profile
A profile is a script that runs before the main script, or before entering interactive mode, and can be used to set up a scripting environment customized for the user or the installation.
To run scripting commands in a profile, execute wsadmin.sh with the -profile option, and place the commands you want to execute into the profile. For example...
Using Jacl
wsadmin.sh -profile alprof.jaclwhere alprof.jacl contains the following...
set apps [$AdminApp list] puts "Applications currently installed:\n$apps"Using Jython
where alprof.py contains the following...wsadmin.sh -lang jython -profile alprof.pyapps = AdminApp.list() print "Applications currently installed:\n " + apps
Troubleshoot
To customize the script environment, specify one or more profiles to run.
A message like WASX7213I: This scripting client is not connected to a server process when trying to start wsadmin indicates that either the server process is not running, the host machine where it is running is not accessible, or that the port or server name used by wsadmin is incorrect.
Verify that one is using the right port number to communicate with the administrative console or wsadmin server using the following steps...
- Look in SystemOut.log
- The line ADMC0013I: SOAP connector available at port nnnn indicates the port that the server is using to listen for wsadmin functions.
- The property com.ibm.ws.scripting.port in...
$WAS_HOME/properties/wsadmin.properties...controls the port used by wsadmin to send requests to the server. If it is different from the value shown in the SystemOut.log file , either change the port number in the wsadmin.properties file, or specify the correct port number when starting wsadmin by using the -port port_number property on the command line.- The message SRVE0171I: Transport http is listening on port nnnn (default 9090) indicates the port the server uses to listen for administrative console requests. If it is different than the one specified in the URL for the administrative console, change the URL in the browser to the correct value. The default value is http://localhost:9090/admin.
- Use the TCP/IP ping command to test that the hostname where the appserver or deployment manager is executing, is reachable from the system where the browser or wsadmin program are being used. If one is able to ping the hostname, this indicates that there are no firewall or connectivity issues.
- If the host where the appserver or deployment manager is running is remote to the machine from which the client browser or wsadmin command is running, ensure that the appropriate hostname parameter is correct:
- The hostname in the browser URL for the console.
- The -host hostname option of the wsadmin command that is used to direct wsadmin to the right server
- Tracing the administrative component: WAS technical support might ask one to trace the administrative component for detailed problem determination. The trace specification for this component is com.ibm.websphere.management.*=all=enabled:com.ibm.ws.management.*=all=enabled"