Modifying variables using scripting
Use scripting and the wsadmin tool to modify variables in WebSphere Application Server.
Before you begin
Before starting this task, the wsadmin tool must be running. See the Starting the wsadmin scripting client article for more information.
About this task
Perform the following steps to modify a WebSphere Application Server variable:
Procedure
- There are two ways to perform this task. Choose one of the following:
- Using the AdminTask object:
Using Jacl:
$AdminTask setVariable {-interactive}Using Jython:
AdminTask.setVariable (['-interactive'])
- Using the AdminConfig object. The following examples modify the DB2_JDBC_DRIVER_PATH variable on the node level:
Using Jacl:
set varName DB2_JDBC_DRIVER_PATH set newVarValue C:/SQLLIB/java set node [$AdminConfig getid /Node:myNode/] set varSubstitutions [$AdminConfig list VariableSubstitutionEntry $node] foreach varSubst $varSubstitutions { set getVarName [$AdminConfig showAttribute $varSubst symbolicName] if {[string compare $getVarName $varName] == 0} { $AdminConfig modify $varSubst [list [list value $newVarValue]] break } }Using Jython:
varName = "DB2_JDBC_DRIVER_PATH" newVarValue = "C:/SQLLIB/java" node = AdminConfig.getid("/Node:myNode/") varSubstitutions = AdminConfig.list("VariableSubstitutionEntry",node).split(java.lang.System.getProperty("line.separator")) for varSubst in varSubstitutions: getVarName = AdminConfig.showAttribute(varSubst, "symbolicName") if getVarName == varName: AdminConfig.modify(varSubst,[["value", newVarValue]]) break
- Save the configuration changes. See the Saving configuration changes with the wsadmin tool article for more information.
- In a network deployment environment only, synchronize the node. See the Synchronizing nodes with the wsadmin tool article for more information.
Related tasks
Using the AdminConfig object for scripted administration Related reference
Commands for the AdminConfig object