Set global variables from Manager/AGI/etc

Hi,

Is there a way to, by way of any of the external control interfaces of Asterisk, set a global variable?

Here’s what I’m doing (you might laugh, but hey it’s fun)… My apartment building uses controlled entry done by phone. When you dial someone’s apt on the entry, it calls them, and the user hits 6 to activate the door unlock mechanism.

Since I once went outside forgetting my building key (and in the process having to wake my roommate so she could let me in via the phone system), I decided to experiment with a way to setup Asterisk to allow me in to the apartment building after pre-existing authentication.

I setup some dialplan functions to do just that, and they work fine if I call into my Asterisk from my cell phone and navigate to the proper extension to input my password. After I’ve input the correct password, I set a global variable in my dialplan to indicate that, if the apartment system calls the FXO line, the system should answer immediately and play a “6” tone. This is handled in the dialplan using callerID matching and GotoIf.

Now that covers me if I have my phone, but let’s suppose I get really absentminded and go downtown without keys or my cell. Or let’s suppose my cell is dead. Yeah yeah I’m being an extremist here but I’m also doing this half for fun as well. :smile: In that instance I want the ability to login to my system on someone else’s computer and “schedule” a door unlock for when I return home. I could do this via an SSH to my linux box, or even better, requesting a webpage and inputting a password which will spawn a Perl script that connects to Manager via telnet.

I need to be able to set the global variable that indicates the call should be answered and the unlock tone played instantly. However I can’t find any way to set that global variable except from within the dialplan itself.

While this is really a silly use of this system, I’d imagine some people could think of some more useful ways to make use of this type of setup. Basically it’s pre-authenticate by phone, global var set, then another extension checks that var, and if set, acts on it then unsets.

So… Can you set a global variable via Manager or via AGI? Or is there a better way to do this I’m not aware of?

Flint

Hello Flint,

You can set a global variable using this AGI cmd

“EXEC SetGlobalVar <var_name>=”

Works for me …

Noel

Okay, now call me a n00b if you like, but… How can I do AGI from a web script? AGI seems to be just for running things from the dialplan. Can I somehow initiate AGI from a perl script executed from a web url request?

Sure you can do it, see voip-info.org/wiki/view/Aste … rl+library for useful infos about.

Marco Bruni