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.
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.
On 6/21/07, Ronaldo Z. Afonso <ronaldoafonso at gmail.com> wrote:> 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.Things written to STDERR only go to the console on which Asterisk was started. If you're using the stock safe_asterisk script to start Asterisk, this would end up being TTY 9. You may want to use the VERBOSE command instead, so that information is logged to the Asterisk command-line interface. -Jared