Question

i have basic python agi code with pyst lib as:

extensions.conf

[from-internal]
exten => _.,1,answer()
exten => _.,2,AGI(test.py)

i have test.py in /var/lib/asterisk/agi-bin as

#!/usr/bin/python
import sys
import os
from agi import AGI
def test_call(agi = None,text = ""):
    agi.say_alpha(text, "#")
    agi.hangup()
if __name__ == "__main__":
    text = 'abcdefr'
    agi = AGI()
    test_call(agi,text)

and i have one file agi.py which is get from pyst lib.

when i try to call to this agi i get this issue

Executing [123@from-internal:1] Answer("SIP/12345-00000016", "") in new stack
[Mar 14 00:01:29] NOTICE[2790]: res_rtp_asterisk.c:2358 ast_rtp_read: Unknown RTP codec 126 received from '169.254.38.82:20338'
    -- Executing [123@from-internal:2] AGI("SIP/12345-00000016", "test.py") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/test.py
 test.py: Failed to execute '/var/lib/asterisk/agi-bin/test.py': No such file or directory
    -- Auto fallthrough, channel 'SIP/12345-00000016' status is 'UNKNOWN'
    -- Executing [h@from-internal:1] Hangup("SIP/12345-00000016", "") in new stack
  == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/12345-00000016'

i see that i have this file in /var/lib/asterisk/agi-bin which 777 permission.

Please suggest to get this basic script work.

thank all in advance

Was it helpful?

Solution

There can be 2 reason for such error:

  1. no file /var/lib/asterisk/agi-bin/test.py in that location or it not accessable by asterisk for some reason - linux general permission issue.
  2. file /var/lib/asterisk/agi-bin/test.py, but no some libraries(python give same error). This one is more likly. Try execute script manual from asterisk user and see what it say.

Recomendation: Use FastAGI instead of AGI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top