
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
432
|
Chapter 17: Asterisk Reference
automatically remove extensions when customers’ bills are overdue in an external
billing system.
Consider the following line of Perl:
system("asterisk –r –x add extension $newExt,$newPri,$appl,$args into $context");
This Perl command launches Asterisk in client mode and runs the add extension CLI
command with an entirely dynamic extension definition—one that another part of
the Perl script establishes according to the programmer’s design.
In order to use the CLI wrapper from a CGI script, the web server run-
ning the script must have permission to execute Asterisk. Usually, this
means putting Asterisk and your web server in the same user group.
This could pose a potential security risk, so use this trick with care.
The Asterisk Gateway Interface
One of the most compelling ingredients in the Asterisk recipe, AGI gives developers
the ability to create custom interfaces between the dial-plan and outside systems.
The AGI is to Asterisk what CGI is to a web server. In a nutshell, it allows you to use
your favorite programming language—Perl, Python, Pascal, RealBASIC, whatever—
to affect or control interaction with a telephone user who’s attached to the PBX.
Here a few examples of things you can do with the AGI:
• Show the caller ID of an incoming phone call ...