Utility scripts

The scripting library provides multiple script procedures to automate your application configurations. See the usage information for scripts that set notification options, save configuration changes, and display scripting library information.

Each utility script procedure is located in the app_server_root/scriptLibraries/utilities/V70 directory. Use the following script procedures to perform utility functions:

convertToList

This script converts a string to a list. For example, the AdminApp.list() command returns a string of application names. Use the convertToList script to change the output to a list format, such as ['DefaultApplication', 'a1', 'a2', 'ivtApp', 'query'].

Table 1. convertToList argument description . Run the script to return a string output and set the output to a variable.
Argument Description
variable Specifies the name of the variable that contains the string to convert to a list.

Syntax

AdminUtilities.convertToList(variable)

Example usage

apps=AdminApp.list()
AdminUtilities.convertToList(apps)

debugNotice

This script sets the debug notice text.

Table 2. debugNotice argument description . Run the script to specify the message argument.
Argument Description
message Specifies the message text for the debug notice.

Syntax

AdminUtilities.debugNotice(message)

Example usage

AdminUtilities.debugNotice(Server is started)

getExceptionText

This script displays the exception message for a specific exception type, exception value, or traceback information.

Table 3. getExceptionText argument descriptions . Run the script to specify the type, value, or traceback arguments.
Argument Description
type Specifies the exception type of interest. The exception type represents the class object of the exception.
value Specifies the exception value of interest. The value represents the instance object that is the argument of the exception or the second argument of the raise statement.
traceback Specifies the traceback information of interest. The traceback object contains special attributes, including the line number where the error occurred. Do not assign traceback to a local variable in the function that handles the exception, as this assignment creates a circular reference.

Syntax

AdminUtilities.getExceptionText(type, value, traceback)

Example usage

AdminUtilities.getExceptionText(com.ibm.ws.scripting.ScriptingException
, com.ibm.ws.scripting.ScriptingException: AdminControl service not available
, "")

fail

This script sets the failure message.

Table 4. fail argument description . Run the script to specify the message argument.
Argument Description
message Specifies the message text for the failure notice.

Syntax

AdminUtilities.fail(message)

Example usage

AdminUtilities.fail(The script failed)

fileSearch

This script searches the file system based on a specific path or directory.

Table 5. fileSearch argument descriptions . Run the script to specify the path or directory arguments.
Argument Description
path Specifies the file path to search for a specific file.
directory Specifies the directory to search for a specific file.

Syntax

AdminUtilities.fileSearch(path, directory)

Example usage

[Windows]
Paths = []
Directory = java.io.File(c:\\WebSphere\\AppServer\\scriptLibraries)
AdminUtilities.fileSearch(directory, paths)
[Linux][AIX][z/OS][HP-UX][IBM i][Solaris]
Paths = []
Directory = java.io.File(//WebSphere//AppServer//scriptLibraries)
AdminUtilities.fileSearch(directory, paths)

getResourceBundle

This script displays an instance for the resource bundle of interest.

Table 6. getResourceBundle argument description . Run the script to specify the bundle name argument.
Argument Description
bundleName Specifies the name of the bundle of interest. For example, to get a message object from the ScriptingLibraryMessage resource bundle, specify com.ibm.ws.scripting.resources.scriptLibraryMessage.

Syntax

AdminUtilities.getResourceBundle(bundleName)

Example usage

AdminUtilities.getResourceBundle(com.ibm.ws.scripting.resources.scriptLibraryMessage)

getScriptLibraryFiles

This script displays the file path and file names for each script library file.

Syntax

AdminUtilities.getScriptLibraryFiles()

Example usage

AdminUtilities.getScriptLibraryFiles()

getScriptLibraryList

This script displays each script name in the script library.

Syntax

AdminUtilities.getScriptLibraryList()

Example usage

AdminUtilities.getScriptLibraryList()

getScriptLibraryPath

This script displays the file path to get to the script library files on your file system.

Syntax

AdminUtilities.getScriptLibraryPath()

Example usage

AdminUtilities.getScriptLibraryPath()

help

This script displays help information for the AdminUtilities script library, including general library information, script names, and script descriptions.

Table 7. help argument description . Run the script to obtain information about the script of interest.
Argument Description
scriptName Optionally specifies the name of the AdminUtilities script of interest.

Syntax

AdminUtilities.help(scriptName)

Example usage

AdminUtilities.help(sleepDelay)

infoNotice

This script sets the text for the information notice of a command or script.

Table 8. infoNotice argument description . Run the script to specify the message argument.
Argument Description
message Specifies the message text or a message ID such as Application is installed or resourceBundle.getString(WASX7115I).

Syntax

AdminUtilities.infoNotice(message)

Example usage

AdminUtilities.infoNotice(resourceBundle.getString(WASX7115I))

save

This script saves the configuration changes to your system.

Syntax

AdminUtilities.save()

Example usage

AdminUtilities.save()

setDebugNotices

This script enables and disables debug notices.

Table 9. setDebugNotices argument description . Run the script to specify the debug argument.
Argument Description
debug Specifies whether to enable or disable debug notices. Specify true to enable debug notices, or false to disable debug notices.

Syntax

AdminUtilities.setDebugNotices(debug)

Example usage

AdminUtilities.setDebugNotices(true)

setFailOnErrorDefault

This script enables or disables the fail on error behavior.

Table 10. setFailOnErrorDefault argument description . Run the script to specify the fail on error argument.
Argument Description
failOnError Specifies whether to enable or disable the fail on error behavior. Specify true to enable the fail on error behavior, or false to disable the behavior.

Syntax

AdminUtilities.setFailOnErrorDefault(failOnError)

Example usage

AdminUtilities.setFailOnErrorDefault(false)

sleepDelay

This script sets the number of seconds that the system waits for completion during two operations.

Table 11. sleepDelay argument description . Run the script to specify the delay seconds argument.
Argument Description
delaySeconds Specifies the number of seconds to wait for completion.

Syntax

AdminUtilities.sleepDelay(delaySeconds)

Example usage

AdminUtilities.sleepDelay(10)

warningNotice

This script sets the text to display as the warning message.

Table 12. warningNotice argument description . Run the script to specify the message argument.
Argument Description
message Specifies the non-translated text for the warning notice or a message ID such as resourceBundle.getString("WASX7411W").

Syntax

AdminUtilities.warningNotice(message)

Example usage

AdminUtilities.warningNotice(resourceBundle.getString(WASX7411W))

configureAutoSave

This script enables and disables the automatic saving of configuration changes to the master configuration repository.

Table 13. configureAutoSave argument description . Run the script to specify the autosave argument.
Argument Description
autosave Specifies whether to save configuration changes to the master configuration repository automatically. The default value is true.

Syntax

AdminUtilities.configureAutoSave(autosave)

Example usage

AdminUtilities.configureAutoSave(false)