[asterisk-users] STDERR in AGI

Anthony Francis anthonyf at rockynet.com
Fri Jun 22 16:33:01 CDT 2007


Ronaldo Z. Afonso wrote:
> 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.
>
>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>   
STDERR goes to console.



More information about the asterisk-users mailing list