Asterisk templates

I have to create 700 extensions so i decided to use a template:

exten
disallow = all
allow = g729
hassip = yes
hasiax = now
host = dynamic
qualify = yes
secret = ${EXTEN}
callerid = ${EXTEN}
setvar=trunk=87754${EXTEN}
context=87754${EXTEN}

I did this so that all I have to put in the users.conf file is the following:

7500

I have subsequently been informed that the ${EXTEN} variable cannot be be used out side of extensions.conf. How can I achieve the result that I am looking for. I want to minimize clutter in the configuration file, minimize the effort needed to code a script to generate the extensions as well as keeping things as simple as possible.

Has anyone got any suggestions?

Few things, I don’t think you can set up variables in the way you want. You can try to put them into a common context and set the variables there. For example:

Set the context to [common] and in common set:

exten => _XXXX,1,Set(TRUNK=87754${EXTEN})
exten => _XXXX,n,Set(CALLERID(num)=${EXTEN})
exten => _XXXX,n,Goto(${EXTEN},${EXTEN},1)

Now, for the secret variable, it is VERY bad practice to have the extension being the same as the password. It preferably should be a long password with alpha, numeric, and some special characters. If your setup allowed external connections, it would be trivial to gain access to those extensions and make calls on your dime if they were the same.