AGI with perl cannot run script, but doesn't give error.

General discussions about AsteriskNOW.

Moderators: Moderator, Support

AGI with perl cannot run script, but doesn't give error.

Postby Sofus Albertsen » Thu Sep 06, 2012 3:07 am

I'm Using AsteriskNOW 2,0,2 32 Bit.
I'm trying to just enable a perscript via AGI and Asterisk::AGI lib.
The asterisk log doesn't show any errors, and if i run it by hand, i only get errors about asterisk parameters.
I have included the extension, the perlscript, and lastly the log.
Thank you in advance!

Extension.conf:
exten => 501,1,AGI(test.pl)
same => n,Hangup()

test.pl:
#!/usr/bin/env perl
use strict;
use warnings;
use LWP;
use HTML::TreeBuilder;
use Asterisk::AGI;
# initialize the AGI module and read incoming arguments
$AGI = new Asterisk::AGI;
$AGI->say_number(1984);
my %input = $AGI->ReadParse();
$AGI->verbose('!!!! AGI started');
exit 0;

asterisk log:
[Sep 6 11:14:10] VERBOSE[24723] pbx.c: [Sep 6 11:14:10] -- Executing [501@KontorTelefoner:1] AGI("SIP/00226810bb6a-00000038", "caller_lookup.pl") in new stack
[Sep 6 11:14:10] VERBOSE[24723] res_agi.c: [Sep 6 11:14:10] -- Launched AGI Script /var/lib/asterisk/agi-bin/caller_lookup.pl
[Sep 6 11:14:10] VERBOSE[24723] res_agi.c: [Sep 6 11:14:10] <SIP/00226810bb6a-00000038>AGI Tx >> agi_request: caller_lookup.pl
[Sep 6 11:14:10] VERBOSE[24723] res_agi.c: [Sep 6 11:14:10] <SIP/00226810bb6a-00000038>AGI Tx >> agi_channel: SIP/00226810bb6a-00000038
[Sep 6 11:14:10] VERBOSE[24723] res_agi.c: [Sep 6 11:14:10] <SIP/00226810bb6a-00000038>AGI Tx >> agi_language: da
[Sep 6 11:14:10] VERBOSE[24723] res_agi.c: [Sep 6 11:14:10] <SIP/00226810bb6a-00000038>AGI Tx >> agi_type: SIP
[Sep 6 11:14:10] VERBOSE[24723] res_agi.c: [Sep 6 11:14:10] <SIP/00226810bb6a-00000038>AGI Tx >> agi_uniqueid: localhost.localdomain-1346922850.56
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_version: 1.8.11-cert7
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_callerid: 00226810bb6a
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_calleridname: Tobias
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_callingpres: 0
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_callingani2: 0
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_callington: 0
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_callingtns: 0
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_dnid: 501
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_rdnis: unknown
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_context: KontorTelefoner
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_extension: 501
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_priority: 1
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_enhanced: 0.0
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_accountcode:
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >> agi_threadid: -1218630768
[Sep 6 11:14:11] VERBOSE[24723] res_agi.c: [Sep 6 11:14:11] <SIP/00226810bb6a-00000038>AGI Tx >>
[Sep 6 11:14:12] VERBOSE[24723] res_agi.c: [Sep 6 11:14:12] -- <SIP/00226810bb6a-00000038>AGI Script caller_lookup.pl completed, returning 0
[Sep 6 11:14:12] VERBOSE[24723] pbx.c: [Sep 6 11:14:12] -- Executing [501@KontorTelefoner:2] Hangup("SIP/00226810bb6a-00000038", "") in new stack
[Sep 6 11:14:12] VERBOSE[24723] pbx.c: [Sep 6 11:14:12] == Spawn extension (KontorTelefoner, 501, 2) exited non-zero on 'SIP/00226810bb6a-00000038'
Sofus Albertsen
Newsterisk
 
Posts: 9
Joined: Thu Sep 06, 2012 2:46 am

Re: AGI with perl cannot run script, but doesn't give error.

Postby Sofus Albertsen » Thu Sep 13, 2012 4:10 am

Bump.
Anyone got a solution for this?
Sofus Albertsen
Newsterisk
 
Posts: 9
Joined: Thu Sep 06, 2012 2:46 am

Re: AGI with perl cannot run script, but doesn't give error.

Postby david55 » Thu Sep 13, 2012 6:27 am

Where is the script?

Is it being accessed (ls -lu)?

Is it executable?

Are you running non-root, if so, are all permissions appropriate?

The use of /usr/bin/env seems an unnecessary complication, try running perl directly as the script interpreter.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: AGI with perl cannot run script, but doesn't give error.

Postby Sofus Albertsen » Fri Sep 14, 2012 3:52 am

david55 wrote:Where is the script?

/var/lib/asterisk/agi-bin
david55 wrote:Is it being accessed (ls -lu)?
Is it executable?
Are you running non-root, if so, are all permissions appropriate?

-rwxr-xr-x 1 root root 569 7 sep 16:12 test.pl
david55 wrote:The use of /usr/bin/env seems an unnecessary complication, try running perl directly as the script interpreter.

I have removed the #!/usr/bin/env perl but now i get:

[Sep 14 12:47:47] -- Launched AGI Script /var/lib/asterisk/agi-bin/test.pl
[Sep 14 12:47:47] test.pl: Failed to execute '/var/lib/asterisk/agi-bin/test.pl': Exec format error


I can run a .sh script no problem.
The server is running as user asterisk, but that should be fine.
Sofus Albertsen
Newsterisk
 
Posts: 9
Joined: Thu Sep 06, 2012 2:46 am

Re: AGI with perl cannot run script, but doesn't give error.

Postby david55 » Fri Sep 14, 2012 4:24 am

Unless you have the wrong time set, there is a conflict between your results. One suggests the file wasn't found at all; the other could only happen if it was found.

The script needs to start with a #! line, but I was suggesting that you directly reference /usr/bin/perl (or whatever it is), rather than indirectly via /usr/bin/env and $PATH.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: AGI with perl cannot run script, but doesn't give error.

Postby Sofus Albertsen » Fri Sep 14, 2012 5:18 am

david55 wrote:Unless you have the wrong time set, there is a conflict between your results. One suggests the file wasn't found at all; the other could only happen if it was found.


the times listed in the old post are for 2 different dates eg. i haven't changed the file when i run the ls command.

david55 wrote:The script needs to start with a #! line, but I was suggesting that you directly reference /usr/bin/perl (or whatever it is), rather than indirectly via /usr/bin/env and $PATH.

I have appeded #!/usr/bin/perl in the begining now, and we are back to scratch:

[Sep 14 14:13:06] -- Executing [501@outgoing:1] AGI("SIP/0004133079F3-0000002a", "test.pl") in new stack
[Sep 14 14:13:06] -- Launched AGI Script /var/lib/asterisk/agi-bin/test.pl
[Sep 14 14:13:06] -- <SIP/0004133079F3-0000002a>AGI Script test.pl completed, returning 0
[Sep 14 14:13:06] -- Executing [501@outgoing:2] Hangup("SIP/0004133079F3-0000002a", "") in new stack

so the script runs, but does not run, but i don't get any error messages.
Sofus Albertsen
Newsterisk
 
Posts: 9
Joined: Thu Sep 06, 2012 2:46 am

Re: AGI with perl cannot run script, but doesn't give error.

Postby david55 » Sun Sep 16, 2012 4:50 am

I have to confess that I didn't read the whole original. I assumed that you were saying that the script didn't work at all, but the trace indicates that it probably did do something.

I'm not familiar enough with the AGI modules for perl.
david55
Moves Like Spencer
 
Posts: 12570
Joined: Fri Sep 26, 2008 5:03 am

Re: AGI with perl cannot run script, but doesn't give error.

Postby Sofus Albertsen » Wed Sep 19, 2012 4:16 am

david55 wrote:I have to confess that I didn't read the whole original. I assumed that you were saying that the script didn't work at all, but the trace indicates that it probably did do something.

I'm not familiar enough with the AGI modules for perl.

Fair enough, thanks for your time anyway:)
As i am not that good in AGI nor perl, is there an example of an AGI compatible language fetching something from a website? I don't care about perl, i care about the solution:)
Sofus Albertsen
Newsterisk
 
Posts: 9
Joined: Thu Sep 06, 2012 2:46 am


Return to AsteriskNOW General

Who is online

Users browsing this forum: No registered users and 0 guests