ASTDB Question

I have nine numbers:
111.111.1111
222.222.2222

999.999.9999

I want to store a variable for use, by number. I was thinking AstDB would be the right tool for the job, but wants quite sure how to do it.

The variable will come from a .txt file in in the /etc/asterisk folder.
For example:
the variable for 111.111.1111 would come from the /etc/asterisk/1111111111.txt file.

The .txt file would only contain the variable, the entire content of the file is the variable.
For example, 1111111111.txt would contain:
This whole sentence is the variable.

Questions:
What’s a good way to structure this from a family key perspective? I am having a hard time with this.

Given the command, what’s the DB update command I should use to set the data?

Thanks in advance for any ideas you may have.

Not this.

You should add your variables to one of the conf files that’s already being pulled in and can be modified by hand. Then, in the conf file, set up your variables so that they are enumerated in the file with their associated values. For, for example, in “/etc/asterisk/asterisk/conf” add:

1111111111 = “Text you want associated with 1111111111”
2222222222 = “Text you want associated with 2222222222”
etc.

This way, the variables are all associated in the Asterisk global variables. The only thing that might jack you up here is that the “pure numeric” attribute of the variables might make them look like numbers (even though they are on the left side of the assignment).

If on the other hand, you want to actually add them to the ASTDB, you could write a program that dropped them into the database. The advantage here is that they will be static (until the database is wiped) and can be updated from the Asterisk CLI anytime.

Writing a script to update the values is trivial. In fact, a webpage that updated the variables would be similarly simple, regardless of which method you chose.

1 Like

Do you have any samples on building a simple page to update the variables on a .conf file Dave? This sounds like the direction I would like to go in?

Not really. I wrote one for the SCCP Manager program that I no longer recommend (it was for Asterisk 1.8 and before), but it does have some code for reading the sccp.conf file and making edits to it.

Check GitHub for “Configuration File Editor PHP” and see if any of that prior art looks like it might work

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.