Hi folk,
very new to APM, have a lot questions on assign variable
why sometimes it’s
variables { { expression “mcget {session.logon.last.username}” varname session.sso.token.last.username } { expression “mcget {session.logon.last.password}” varname session.sso.token.last.password } }
but sometimes it has another “expr” in front, what’s the difference?
variables { { expression “expr {[mcget {session.logon.last.password}]}” varname session.logon.last.password2 } }
expr just tells it to evaluate the string, so “1+1” without expr would be “1+1” and with expr would be 2. People tend to use it a lot when it’s not necessarily needed. Personally, I prefer using “return” and returning explicitly what I want.
variables {
{
expression "expr {[mcget {session.logon.last.password}]}"
varname session.logon.last.password2
}
}
In your example, the expr is actually not needed. The above will produce the same result as in the config:
variables {
{
expression "mcget {session.logon.last.password}"
varname session.logon.last.password2
}
}
However, you can evaluate any tcl expression using “expr”. For example:
variables {
{
expression "expr {[string tolower [mcget {session.logon.last.username}]]}"
varname session.custom.user
}
}
Thanks you both for taking time answering my questions.
Thanks you both for taking time answering my questions.