Sharing data in AstDB with 'outside' programs -easiest way?

Hi, can anyone suggest an easy way to read and write the astdb from a perl or php scripting language? So far we have been unable to get perl to talk to it. And have been unable to find any kind of sample scripts.

Even a simple “hello world” example would be wonderful… like a script to fetch the value associated with /myfamily/mykid/mytoken in the database.

Asterisk made it SO easy to work with the Astdb, we’re hoping to find a comparably easy way to write scripts than can read (and maybe write) to the same database. We’re using the AstDb and dialplans very extensively to develop some kinda fun telephony apps.

We’re using trixbox 1.2.3 for the development platform, which has (I think) Berkeley Db 1.85. The trixbox-pre-installed Perl module DB_FILE is v1.809. I have no idea what if any PHP module is installed already with trixbox for accessing the Berkeley database.

Thanks!

Surely SOMEBODY has integrated some kind of back-office application with the ASTDB? Can anyone offer any hints on how they did it?

Have you thought about using something a bit more robust? FirebirdSQL (http://www.firebirdsql.org) is an excellent database that features everything that you could want in a relational database. Triggers, nice stored procedure language, RI, ACID compliant. Runs on linux/unix, windows, etc.

What is a special little treat is that FirebirdSQL is not only a TCP based client/server system (like MySQL, MSSQL, et al), but there is also an embedded version as well! This means that you can ship a small dll with your app (.so for linux) and you get all the functionality of a full fledged client/server database with an embedded database file without having to install a full fledged client/server db! There are many different interfaces available as well: Delphi VCL, .net provider, odbc, oledb, php, java clients, etc.

Opens source and free for commercial use. I use it in all my software products that require storage more complex that a simple ini or xml file. The software mentioned in my signature uses the embedded version of FirebirdSQL.

Why dont you use asterisk system calls or the manager.

Storing or reteiving this way is simple.

Thanks for the replies.

But our question is – and remains – how to access AstDB from an external program. (Running on a different box than the DB is on, a non-Asterisk box most likely.)

Surely SOMEBODY has written an external script to peek or poke the AstDB from Perl or PHP?

Our app is already developed, in the dialplan, using AstDB.

Now we need to access the same database from outside programs so we can build some additional layers of functionality, some web-based, some not.

So – if anyone can give us even a small hint of how to access the Berkeley DB v1 AstDB – even a ‘hello world’ that simply reads ONE item out of the database – we would be very grateful. That’s what we need, is a framework that gets us over the hump of which language/library/access method to use to permit Asterisk and an external App to access the database concurrently.

My mistake. I thought you were looking for an embedded database for use since you liked working with the AstDB.

Just for S & G’s, I did a google and there is a lot out there concerning php and Berkely DB, just mostly for latest version 4 from what I can see.

Sorry.

I appreciate the response, of course.

I ran into the same problem, I could not find a single example that documented how to make it work with AstDB. This time, Google was not my friend… ;(

I could not, for example, even get a definitive answer about concurrent access to AstDb for Asterisk plus another app.

ANY AstDb users out there who know about multiple apps sharing an AstDB?

Hi
What are you intending to do ?

Personaly using system("sudo /usr/sbin/asterisk -rx " . escapeshellarg("database put service status \"$service\"") . " &> /tmp/error"); type commands I access the database to set and change many features such as system service, call forwarding, speedcalls etc.

and

system("sudo /usr/sbin/asterisk -rx \"database show service\" > /tmp/asterisk_service.txt"); $fd=fopen("/tmp/asterisk_service.txt","r"); while ($line=fgets($fd,1000)) { $alltext.=$line;

to read data and display it

As to direct connections I think the answer will be in the source code somewhere.

Since you are talking about doing this from a remote box, your best bet is going to be to leverage the AMI using DBGet and DBPut over a simple TCP socket connection.

see: voip-info.org/wiki/view/Asterisk+manager+API for more information.

Also note that exposing the AMI sock to the open internet is not recommended.