Index is not an integer

Alan DeKok aland at deployingradius.com
Tue Dec 15 15:03:19 CET 2015


On Dec 15, 2015, at 8:54 AM, Franks Andy (IT Technical Architecture Manager) <Andy.Franks at sath.nhs.uk> wrote:
> 
> Hi Alan,
>  First of all thanks for the reply, that helps me understand "xlat's place".
> 
> My real struggle was with what Arran provided yesterday, can't get it to work:

  As with most things, break it down in pieces.

> "%{xlat:%%{control:Tmp-String-3[%{control:Tmp-Integer-0}]%}}"

  Hmm... I'm not sure that works.  The problem is that this is complicated and not simple...

> It use is to refer to the index of Tmp-String-3 via the dynamic integer Tmp-Integer-0. Trouble is, it comes back with an empty string.

  It comes back with a lot more than that.  PLEASE run the server in debugging mode to see what the inputs and outputs are for each stage of expansion.  Honestly, this should be the *first step*.  And you should post it here, too.

  Ignoring the debug output means you will *never* get the problem solved.

> Is it because of what you mentioned ; that 
> 
> control:Tmp-String-3[%{3}] != control:Tmp-String-3[3]

  No.  %{xlat:3} is the same as %{3}.  %{xlat:foo-3} is the same as %{foo-3}, not %{foo-%{3}}.  There's no magical expansion in the middle of a string.

> Do I need to do some regex matching and plug the integer value into the corresponding group by building, for example, a delimited string? Would that work?

  No.  I'd break it down into pieces.  The question is, what does each piece produce?  Build it up in sequence.

	%{control:Tmp-Integer-0}  is...

	%{control:Tmp-String-3[%{control:Tmp-Integer-0}] is ...

  My guess is that won't work, because the normal case is to *not* do xlat expansions on the array offsets.  You might need to build up multiple layers of xlat expansions.

> The apparent downside to that would be to only match a preset number of groups my expression contained, and, if possible, I'd like to match any number of previous "things", within reason. I'm guessing I'm on the edge of what should maybe done in perl / python / whatever, it just seems the tricky bit has been done with the import of mapped sql stuff, can't get over how useful that is, and now I just want to iterate over things in turn, literally the last thing to be done.

  Yup.

  Alan DeKok.




More information about the Freeradius-Users mailing list