Skip to Content
Asterisk: The Future of Telephony, 2nd Edition
book

Asterisk: The Future of Telephony, 2nd Edition

by Jim Van Meggelen, Jared Smith, Leif Madsen
August 2007
Intermediate to advanced
608 pages
20h 33m
English
O'Reilly Media, Inc.
Content preview from Asterisk: The Future of Telephony, 2nd Edition

Name

AGI() — Executes an AGI-compliant application

Synopsis

[E]AGI(program[,arguments])

Executes an Asterisk Gateway Interface-compliant program on the current channel. AGI programs allow external programs (written in almost any language) to control the telephony channel by playing audio, reading DTMF digits, and so on. Asterisk communicates with the AGI program on STDIN and STDOUT. The specified arguments are passed to the AGI program.

The program must be set as executable in the underlying filesystem. The program path is relative to the Asterisk AGI directory, which by default is /var/lib/asterisk/agi-bin/.

If you want to run an AGI when no channel exists (such as in an h extension), use the DeadAGI() application instead. You may want to use the FastAGI() application if you want to do AGI processing across the network.

If you want access to the inbound audio stream from within your AGI program, use EAGI() instead of AGI(). Inbound audio can then be read in on file descriptor 3.

If the channel hangs up prematurely, the process initiated by the AGI command will be sent a HUP signal to tell it that the channel has hung up. If your program does not catch this signal, it will be terminated. You can override this behavior by setting the channel variable AGISIGHUP to 0:

; call the demo AGI program
exten => 123,1,AGI(agi-test)
exten => 123,2,EAGI(eagi-test)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Asterisk: The Future of Telephony

Asterisk: The Future of Telephony

Jim Van Meggelen, Jared Smith, Leif Madsen
Switching to VoIP

Switching to VoIP

Theodore Wallingford

Publisher Resources

ISBN: 9780596510480Errata Page