Are there some errors in the DeadAGI script?

hangup.php

#!/usr/local/bin/php -q

<?php ob_implicit_flush(true); set_time_limit(6); echo "-------------------------------${CDR(billsec)}-------------------------\n"; exit; ?>

extensions.conf

exten => _X.,1,Answer
exten => _X.,2,AGI(dial.php)
exten => _X.,3,Hangup()
exten => h,1,DEADAGI(hangup.php|${CDR(billsec)})

dial.php can be excuted well, but hangup.php can not! Why?

Well, assuming you fixed your previous post error, so you probably using 1.4 or you patched 1.2.x with that patch to that CDR() values dont get ‘lost’, then echo will not print the the * cli, you have to

fwrite(STDERR, “${CDR(billsec)}\n”);

to get output to the cli.

Hi,

this looks like the php code is preprocessed by asterisk, using asterisk method of inserting values of variables???

Musicman

hangup.php

#!/usr/local/bin/php -q

<?php ob_implicit_flush(true); set_time_limit(6); $stdout = fopen('php://stdout', 'w'); puts($stdout, "--------------------------------------------------------\n"); exit; ?>

extensions.conf

exten => _X.,1,Answer
exten => _X.,2,AGI(dial.php)
exten => _X.,3,Hangup()
exten => h,1,DEADAGI(hangup.php)

Output in CLI after hangup

-- Executing DeadAGI("IAX2/58.34.241.239:44165-1", "hangup.php") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/hangup.php
-- AGI Script hangup.php completed, returning 0
-- Hungup 'IAX2/58.34.241.239:44165-1'

localhost*CLI>

It looks the script still can not work! How can I find Patch for Asterisk? I use the Asterisk 1.2.13

what you want to do?
i don`n understand of PHP, but i think that AGI run the script well.
you can not use ${CDR(billsec)} inside the script!

Hi, jud, I just want to get the duration the call last.

Can you tell me how to implement it in AGI/DeadAGI?

To see output from an AGI, since AGI only sends its output to the first Asteisk console, you have to run int with asterisk -cvvvvvvvvvvvvvvvvv

put this in extensions.conf
exten => h,1,DeadAGI(/xxx/xxx.agi|${CALLERID(NUMBER)}|${ANSWEREDTIME}

make xxx.agi script

#!/usr/bin/perl
use warnings;
use strict;
use Asterisk::AGI;

my $AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();

my $caller = $ARGV[0];
my $billsec = $ARGV[1];

open (file_1, “>> /xxx/$caller”);
print file_1 ("$billsec\n");
close file_1;

you must install Perl module for Asterisk:
asterisk.gnuinter.net/files/aste … .09.tar.gz
(I use version 0.08, but this I think will work too :smile:)

don’t forgot to chek file permissions. that’s it.

now, everyone who make a call and the call is with status ANSWERED, the billsec will be writen in a file with name of the number of caller.
i hope this will help you.

i forgot to tell you, that i use Asterisk 1.4.0. it’s possible to have a different way in AGI syntax. check the link, that i send in the previous post.

Thank you jud, I will try according to your advice:)