+

Search Tips   |   Advanced Search

Modify variables using scripting


Use scripting and wsadmin to modify variables in the application server.

Complete the following steps to modify an appserver variable:

 

  1. Launch the wsadmin scripting tool using the Jython scripting language.

  2. There are two ways to perform this task. Choose one of the following:

    • Use the AdminTask object:

      • Jacl...

        $AdminTask setVariable {-interactive}

      • Jython...

        AdminTask.setVariable (['-interactive'])

    • Use the AdminConfig object.

      The following examples modify the DB2_JDBC_DRIVER_PATH variable on the node level:

      • 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
           } 
        }
        

      • 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
        

  3. Save the configuration changes...

    AdminConfig.save()
    

  4. In a network deployment environment only, synchronize the node. Use the syncActiveNode or syncNode scripts in the AdminNodeManagement script library to propagate the configuration changes to node or nodes.

    • Use the syncActiveNodes script to propagate the changes to each node in the cell...

      AdminNodeManagement.syncActiveNodes()

    • Use the syncNode script to propagate the changes to a specific node, as the following example demonstrates:

      AdminNodeManagement.syncNode("myNode")

 

Related tasks


Use the AdminConfig object for scripted administration

 

Related


Server settings configuration scripts
Commands for the AdminConfig object