Chapter 8. Administration with scripting 331
script libraries to use and merge them into your own script file. Save the custom script as a
Python file, and run it from the command line.
Example 8-13 shows a Python file containing two script library commands.
Example 8-13 The script for test.py
# Writting by Jython
# Script file name : test.py
AdminServerManagement.checkIfServerExists("sys1Node01", "Amember21")
AdminServerManagement.createApplicationServer(“sys1Node01”, “Amember21”)
Example 8-14 shows how to invoke the script.
Example 8-14 Using the invoke test.py script
C:\WebSphereV8.5\AppServer\bin>
C:\WebSphereV8.5\AppServer\bin>wsadmin.bat -lang jython -f C:\temp\test.py
Customizing scripts
Customizing scripts is an advanced use of the script mode. You can add customized code
written in Python or Jython to your script file (the one that calls the script libraries).
When customizing a script:
1. Run each Jython script in interactive mode and then verify the syntax and the result.
2. Create the script file that will call the script libraries by combining all Jython scripts. Verify
that the results are as you expect.
3. Add your additional wsadmin commands, written in Python and then verify that the
customized script does the work that you intended.
8.6.2 Displaying help for script libraries
You can use the AdminLibHelp script to display each script within a script library. For example,
the following command displays each script in the AdminApplication script library:
print AdminLibHelp.help("AdminApplication")
You can use the help script to display detailed descriptions, arguments, and usage
information for a specific script. For example, the following command displays detailed script
information for the listApplications script in the AdminApplication script library:
print AdminApplication.help('listApplications')
Example 8-15 shows sample code for displaying help information for the
createApplicationServer procedure in the AdminServerManagement script.
Example 8-15 Help information for a procedure in createApplicationServer
wsadmin>print AdminServerManagement.help('createApplicationServer')
WASL2004I: Procedure: createApplicationServer
Note: Do not modify the script libraries. If you need to customize the scripts, you can copy
parts of the library code to other files and modify the copied code to improve it or to better
suit your needs.