# # modEnv - procedure for modifying the Environment attribute of one or # more application servers in a domain. The specified environment variable # is modified (or added if it is not present), and the values of other # variables are retained. # # Arguments: # # server - the fully qualified name of the application server whose # Environment attribute is to be modified. # # variable - the name of the environment variable to modify. # # value - the new value of the environment variable. # # To modify the Environment attribute of multiple servers, use # the Tcl foreach command, for example # wscp> foreach server [ApplicationServer list] {modEnv $server TEST_VARIABLE 3.5} # # The file init.tcl must be loaded prior to using this procedure. proc modEnv {server variable value} { set oldEnv {} getAttrs $server attr Environment if {[info exists attr(Environment)]} {set oldEnv $attr(Environment)} # append to environment if not found; replace if it is found set i [lsearch -regexp $oldEnv ^$variable=] if {$i == -1} { set newEnv [lappend oldEnv "$variable=$value"] } else { set newEnv [lreplace $oldEnv $i $i "$variable=$value"] } set attr(Environment) $newEnv setAttrs $server attr } modEnv