Agi callback perl

hello all,
I tryed to do an callback agi in perl
but it don’t work
i don’t know if it is my asterisk or my script which don’t work!

thank you

my scipt:

#!/usr/bin/PERL

use Asterisk::AGI;
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $caller id = $input{‘caller id’}; # on recuperer le callerid

normalisation du numero passe {country code}{number}

suppression des caracteres non numeriques

$callerid =~ s/[^\d]//g;

#mise en forme du fichier .call dans le spooler de asterisk
open (FSOR,’>>/var/spool/asterisk/outgoing/rappel.call’);
print FSOR “Channel : $callerid \nMaxRetries: 3 \nRetryTime: 40 \waittime: 25 \context: $context \extension: $extension \priority: 1 \n”;
close FSOR;

you shouldn’t create the .call file in the outgoing directory … create it somewhere else and move it when you’re finished writing to it. otherwise, the way Asterisk agressively scans the directory can cause problems with open files. make sure you get the right permissions on the file too.

I modify it by '/tmp/rappel.call’
and after I add in extension.conf a line which move into the spooler
but don’t work

ok, now i’ve had a closer look at yours … you’re missing bits !

here’s an example of a call file in Perl [code]my $extension = $query->param(‘ext’);
my $destination = $query->param(‘sd’);

write file

my $myfile = “/var/spool/asterisk/”.$extension.".call";
my $destfile = “/var/spool/asterisk/outgoing/”.$extension.".call";

open(EXTEN,">$myfile");
print EXTEN “Channel: SIP/$extension\n”;
print EXTEN “MaxRetries: 1\n”;
print EXTEN “RetryTime: 60 \n”;
print EXTEN “WaitTime: 30 \n”;
print EXTEN “Context: system-speeddials\n”;
print EXTEN “Extension: $destination\n”;
print EXTEN “Priority: 1\n”;
close(EXTEN);

move file

system(“mv $myfile $destfile”);
[/code]

show us the outputted .call file too

I don’t know why but I tryed your example and it doesn’t work

me neither … it’s used > 100 times a day by a couple of my clients (albeit in a cgi script)

you going to post your call file here then ?

I could see in my logs that I had some problems ith my asterisk!

is it possible to have a simple configuration of extensions.conf for example
to try it

thank you

as i said, my example uses call files as part of a cgi script. i’ve never had a need to do a call back via the dialplan.

explain what you’re trying to do and post the code you’re using now.

I try to do an AGI in perl.
when I call asterisk for example 1000

exten => 1000,1,Answer()
exten => 1000,2,AGI(rap.agi)
exten => 1000,3,HangUp

when I call 1000, asterisk execute rap.agi, hangup and call me back with the .call file in the spooler.

4th time lucky. post all your code here. we’ve seen the extensions.conf entry, now we need to see the call file your Perl script creates, and the Perl script itself.

the problem is that no call file are created!
and asterisk retourn error 500 server

ok, i’ll try again. here is an example i justr knocked up. you call 1000, it writes the .call file and hangs up. then you get a call and it dumps you out to *63, my extension for an echo test.

rap.agi[code]#!/usr/bin/perl -w

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

my $extension = $input{“callerid”}; # Where we’re going to call

write file

my $myfile = “/var/spool/asterisk/”.$extension.".call";
my $destfile = “/var/spool/asterisk/outgoing/”.$extension.".call";

open(EXTEN,">$myfile");
print EXTEN “Channel: SIP/$extension\n”;
print EXTEN “MaxRetries: 1\n”;
print EXTEN “RetryTime: 60 \n”;
print EXTEN “WaitTime: 30 \n”;
print EXTEN “Context: default\n”;
print EXTEN “Extension: *63\n”;
print EXTEN “Priority: 1\n”;
close(EXTEN);

move file

system(“mv $myfile $destfile”);

exit 0;[/code]extensions.confexten => 1000,1,Answer() exten => 1000,2,AGI(rap.agi) exten => 1000,3,HangUp()

works just fine. not sure what you’d use it for though !

edit : be careful of line wrapping !!

i give you my log screenshot

http://fcois93.free.fr/screenshot.JPG

and I can see that no .call file are create

[quote=“fcois93”]i give you my log screenshot[/quote]that’s nice. not sure what to do with it as you haven’t posted any details about the extension or perl you used.

perhaps this might help ? catb.org/~esr/faqs/smart-questions.html

I use your perl script:

#!/usr/bin/perl -w

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

my $extension = $input{“callerid”}; # Where we’re going to call

write file

my $myfile = “/var/spool/asterisk/”.$extension.".call";
my $destfile = “/var/spool/asterisk/outgoing/”.$extension.".call";

open(EXTEN,">$myfile");
print EXTEN “Channel: SIP/$extension\n”;
print EXTEN “MaxRetries: 1\n”;
print EXTEN “RetryTime: 60 \n”;
print EXTEN “WaitTime: 30 \n”;
print EXTEN “Context: maison\n”;
print EXTEN “Extension: 101\n”;
print EXTEN “Priority: 1\n”;
close(EXTEN);

move file

system(“mv $myfile $destfile”);

exit 0;

and in my extensions.conf :

[maison]

exten => 1000,1,Answer
exten => 1000,2,AGI(rap.agi)
exten => 1000,3,HangUp

thank you for helping

so looking at your screenshot and the perl script, you initiated a call to SIP/101 and then attempted to connect it to SIP/101@maison.

is that what you wanted to do ?

I call asterisk with SIP/101@maison
and I want that he call me back (SIP/101@maison)

http://fcois93.free.fr/screenshot2.JPG[/url]

ok, i get that. but what do you want to do with the callback ? produce a dialtone, connect you elsewhere ?