Set gobal var w/ file contents

I have a global val— val-one and I want the contents of /etc/asterisk/folder/john to be its value. What I have in there is 9876, just 4 digits.

Right now I just do the following:
val-one=9876
That is hard coded and I would rather assign val-one whatever is in that file at time of start up.

I have tried using system() several ways but aren’t using it correctly enough to avoid error messages.
SetGlobalVar(val-one=system(stuf))
SetGlobalVar(val-one=$[system(stuf)])
both made errors for me.

I have searched voip-info.org and not found enough to help me to get it to work right.

To HALF answer my question. I need an add on, it is not builtin. The addon is called app_backticks.c It serves both as an application or can used as a function.

One web site offers debian installs (is that *.ram ?) Inside is file called app.backticks.so is that all that i need ? or do I need the *.h files plus what more ?

If your goal is to preload stuff at start, there can be several alternatives. The simplest would involve a custom start script that replaces values in configs with those in files before actually starting.

But your attempt to use System() application seems to suggest that you want to dynamically load global variables. There are also several alternatives to do this. For example, you can use System() to run the script to replace values in config files, then force Asterisk to reload the config from the script or System().

Give example of how I would go about doing the above ? Specifically how to replace values in config files. I have done the reload in code. Does that mean I am limited to change made in *.conf files ONLY ?

Let’s try a really dumb method (untested codes):

In extensions.conf:

[dynamic-var] exten => s,1,NoOp(About to replace val-one in extensions.conf with content of /etc/asterisk/folder/john) exten => s,n,System(/usr/local/bin/myconf.sh) exten => s,n,Hangup()

Now /usr/local/bin/myconf.sh reads like:

[code]#!/bin/sh
cat < /etc/asterisk/extensions.conf
[globals]
val-one=cat /etc/asterisk/folder/john
[rest of extensions.conf …]
EOF

/usr/bin/asterisk -x “extensions reload” #or “dialplan reload” if 1.4
[/code]

I’m not sure what you want to change other than *.conf but you can change pretty much anything that the system allows the Asterisk user to.