Variables in #include statments


#1

Are variables in #include statements supported?

This doesn’t seem to work…
sip.conf:
[user1]
context=from_phone
accountcode=user1

extensions.conf:
[from_phone]
#include “inc/${ACCOUNTCODE}-blocked.conf”

inc/user1-blocked.conf:
exten => _1900X.,1,Answer
exten => _1900X.,n,Wait,1
exten => _1900X.,3,Playback(tt-weasels)
exten => _1900X.,4,Hangup

When I do a show dialplan, there’s no mention of the _1900X extension. Anyone ever done this?

The more I think about it, the more I think it would be best to manage the ENTIRE dial plan from one or more AGI scripts. We can check blocked numbers, extensions from a database and execute whatever logic we so desire. I would have liked to have investigate AEL but considering it can’t process #includes at all, and you have to restart asterisk completely after making a modification, that rules it out.

Can anyone advise any dangers or limitations of doing this? Hopefully I can get more functionality than I can with the very limited extensions.conf


#2

Yes, they are. As an include is nothing but inserting another file within the file.


#3

Doesn’t look like it works to me.


#4

#include is just including a filename, you may not use a variable, as the #include only gets read upon load, not each transaction.

Of course, there may be variables used inside the file included (that is what I was referring to having only read the title of the thread). All an include is, is the ability to break your extensions.conf into smaller more manageable pieces.