I sent this to the list a while back, is there a FAQ for the perl
module?  This works well with either AGI or CGI.

NOTE:  The perl debugger is completely broken when it comes to UTF-8 so
if your code uses any XML you will find really odd problems.

So this is the process we use:

Write a small shell script.
If the perl AGI is foo.pl, our script would be:
        #!/bin/bash

        ulimit -t 30

        if [ -f /tmp/debug_tty ]
        then
            TTY=`cat /tmp/debug_tty`
            export PERLDB_OPTS="TTY=$TTY ReadLine=0"
            DEBUG=5 perl -d foo.pl $* 2> $TTY
            exit $?
        else
            perl foo.pl $* 2> /tmp/foo-stderr-$$.log
            exit $?
        fi

To use the debugger replace this in the dialplan as your AGI.
with no special operation this will run just like the perl script does.

However if you log in to a shell on the server, and run:

echo `tty` > /tmp/debug_tty && chmod 666 `tty` && \
chmod 644 /tmp/debug_tty && sleep 12341234; rm -f /tmp/debug_tty

The next time the AGI launches it start in the debugger inside this
terminal that's in "sleep".  Now you need to remember to remove
the /tmp/debug_tty file or you'll get rather undesirable behavior.

Also, just to be safe, delete the /tmp/debug_tty and above command
between each instance.  If 2 people try to use the same AGI at once, the
behavior is not fun.

Good luck.

On Sat, 2005-07-30 at 17:59 +0500, code select wrote:
> I found it's very hard to debug agi scripts...
> I studied programming them from examples and most of them just print
> debug messages to STDERR. But where do they go to? I do not get them
> in the asterisk console. (asterisk -r) though I set the highest level
> of verbosity and debug (I used agi debug command too) but still
> nothing from the scripts! The other scripts use $AGI->verbose($msg,
> $level) but from my scripts it errors as if I send unexistant commands
> to the asterisk.
> Please suggest the best practices or point what I do wrong.
> 
> ---
> code.select
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
-- 
Chris Tooley
512-646-1507
[EMAIL PROTECTED]

Reply via email to