I have an expression that reads the user-name attribute of a datasource:
[standalone@localhost:9990 /] /subsystem=datasources/xa-data-source=MYDATASOURCE:read-attribute(name=user-name)
{
"outcome" => "success",
"result" => "DS_USERNAME"
}
I would like to store that result in a variable, so that I can use it in other expressions.
If I simply use set, it will set the variable as the expression itself, rather than the result:
[standalone@localhost:9990 /] set DSUSER=/subsystem=datasources/xa-data-source=MYDATASOURCE:read-attribute(name=user-name)
[standalone@localhost:9990 /] echo $DSUSER
/subsystem=datasources/xa-data-source=MYDATASOURCE:read-attribute(name=user-name)
[standalone@localhost:9990 /] $DSUSER
{
"outcome" => "success",
"result" => "DS_USERNAME"
}
I really just want to set DSUSER somehow, such that 'echo $DSUSER' results in 'DS_USERNAME':
[standalone@localhost:9990 /] echo $DSUSER
DS_USERNAME
Is there any way I could do that? (I've tried piping it to grep, but this grep doesn't support regex capture groups)
I believe you can do it using backticks (`) like: