Modifying variables using scripting

 

Modifying variables using scripting

Before starting this task, the wsadmin tool must be running. See the Starting the wsadmin scripting client article for more information.

Perform the following steps to modify a WebSphere Application Server variable:

  1. The following examples modify the OS400_TOOLBOX_JDBC_DRIVER_PATH variable on the node level:

    Using Jacl:

    set varName OS400_TOOLBOX_JDBC_DRIVER_PATH
    set newVarValue /home/myuserid/toolbox 
    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 = "OS400_TOOLBOX_JDBC_DRIVER_PATH"
    newVarValue = "/home/myuserid/toolbox"
    
    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

  2. Save the configuration changes. See the Saving configuration changes with the wsadmin tool article for more information.

  3. In a network deployment environment only, synchronize the node. See the Synchronizing nodes with the wsadmin tool article for more information.



Related concepts
AdminConfig object for scripted administration

Related reference
Commands for the AdminConfig object