AGI [HELP Required]

Hi All,

I am facing a problem while transferring control back and forth from AGI scripts to Asterisk. or Lets say the control is not being transferred to AGI scripts only.

The command I am using to transfer to the AGI is:

exten => s,2,agi,


exten => s,2,AGI(


exten => s,2,AGI(filename.agi)

None of them seems to work.
Any help in this regard would be appreciated.


is the file in /var/lib/asterisk/agi-bin (or your designated agi directory), is it executable, and owned/accessible by the user that Asterisk runs as ?

Yes, it is located in the var/lib/asterisk/agi-bin directory and i am working as a root user.

The agi file is as follows:

import sys
import time

def getEnv():
env = ""
rtn = []
while (env != “\n”):
env = sys.stdin.readline()
return rtn

def sendAgi(str):
var = sys.stdin.readline()
return var

sys.stderr.write(“ is starting…\n”)

Read and ignore AGI environment

agi = getEnv()


var = sendAgi(“STREAM FILE gsmfile “”\n”)


var = sendAgi("SET VARIABLE P " + str(time.time()) + “\n”)


On the asterisk CLI type

agi debug

This will turn AGI debugging on.
Run the dialplan and show the CLI output when the AGi script is run.

I get this error message when i do agi debug

bash: agi: command not found

at the CLI CLI > agi debug

at the CLI :

CLI> agi debug
No Such Command ‘agi’ (type ‘help’ for help)

Hi aman,

Start asterisk using the command asterisk -cvvvvv
You get some messages and then you get a CLI (Command Line Interface) like this :


Now type agi debug at the CLI

If you are still getting the same error then maybe you are using an ancient
version of asterisk.

Hi All,

It still gives me the error message:

CLI> agi debug

No such command ‘agi’ (type ‘help’ for help)

Please help me to figure out this issue.