List currently active websphere variables in server using wsadmin

environment-variableswebspherewsadmin

how can I list using the wsadmin tool the currently active websphere variables and its values in a node/server ? Additionally, is there a way to filter the results using regular expressions ?

Thanks

Best Answer

The AdminTask.showVariables command is a convenient method that allows you to retrieve WAS environment variables. These are returned as a string representation when obtaining a list of variables, though, so it's not as convenient for this purpose.

Alternatively, you can use the AdminConfig. I'm not aware of any way to filter the results of these commands using regular expressions. The AdminConfig.list command allows filtering by regular expressions, but I haven't been able to get this to work with environment variables. My guess is that it filters based on the name attribute, but because the variable entry name is actually symbolicName, it doesn't work. You can still filter the results after retrieving all variables by applying some custom conditionals to test the symbolicName.

import re    
vars = AdminConfig.getid("/Node:%s/VariableMap:/VariableSubstitutionEntry:/" % node).splitlines()
for var in vars :
    name = AdminConfig.showAttribute(var, "symbolicName")
    if ( re.match("yourRegularExpression", name) ) :
        value = AdminConfig.showAttribute(var, "value")
        print "%s = %s" % (name, value)
Related Topic