Debugging AGI programs , as with any other type of program, can be frustrating.
Luckily, there are two advantages to debugging AGI scripts. First, since all the communications between
Asterisk and the AGI program happen over
STDOUT (and, of course,
STDERR), you should be able to run your AGI
script directly from the operating system. Second, Asterisk has a handy
command for showing all the communications between itself and the AGI
As mentioned above, you should be able to run your program directly from the operating system to see how it behaves. The secret here is to act just like Asterisk does, providing your script with the following:
A list of variables and their values, such as
A blank line feed (
indicate that you’re done passing variables.
Responses to each of the AGI commands from your AGI script.
200 response=1 is sufficient.
Trying your program directly from the operating system may help you to more easily spot bugs in your program.
The Asterisk command-line interface has a very useful command
for debugging AGI scripts, which is called (appropriately enough)
agi debug. If you type
agi debug at an Asterisk console and then
run an AGI, you’ll see something like the following:
-- Executing AGI("Zap/1-1", "temperature.php") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/temperature.php AGI Tx >> agi_request: temperature.php ...