[asterisk-users] STDERR in AGI

Ronaldo Z. Afonso ronaldoafonso at gmail.com
Thu Jun 21 20:35:50 CDT 2007


Hi all,

I just started programming using AGI and I have a simple question about 
STDERR.
If I understood it right, all the messages sent to "STDERR" should be 
shown in the Asterisk console, but using the following python code I 
just can't see anything.

#!/usr/bin/python
#
#       File: /var/lig/asterisk/agi-bin/agi-test.py
#
#       Description: An AGI Script
#

import sys

env = {}
tests = 0

while True:
        line = sys.stdin.readline().strip()
        if line == '':
                break
        key,data = line.split(':')
        if key[:4] != 'agi_':
                sys.stderr.write("Did not work!\n")
                sys.stderr.flush()
                continue
        key = key.strip()
        data = data.strip()
        if key != '':
                env[key] = data

sys.stderr.write("AGI Environment Dump:\n")
for key in env.keys():
        sys.stderr.write(" -- %s = %s\n" % (key,env[key]))
        sys.stderr.flush()

##########################################################################

This code comes from the book "Asterisk: The future of the Internet" and 
it is being activated by an extension like that:

exten => 123,1,Answer()
exten => 123,2,AGI(agi-test.py)

Any help would be appreciated.

Ronaldo.





More information about the asterisk-users mailing list