[HELP]Asterisk debug mode "failed to execute '/.../' no

hi guys, I have to say I’m relatively new to asterisk.

I’m trying to execute an agi script from an extention and it gives me following error. Here is my agi debug lines.

-- Executing [333@incoming-agi-custom:1] Answer("SIP/210-082516b8", "") in new stack -- Executing [333@incoming-agi-custom:2] BackGround("SIP/210-082516b8", "main-menu") in new stack -- <SIP/210-082516b8> Playing 'main-menu' (language 'en') -- Executing [333@incoming-agi-custom:3] AGI("SIP/210-082516b8", "script.agi") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/script.agi AGI Tx >> agi_request: script.agi AGI Tx >> agi_channel: SIP/210-082516b8 AGI Tx >> agi_language: en AGI Tx >> agi_type: SIP AGI Tx >> agi_uniqueid: 1235571706.15 AGI Tx >> agi_callerid: 210 AGI Tx >> agi_calleridname: device AGI Tx >> agi_callingpres: 0 AGI Tx >> agi_callingani2: 0 AGI Tx >> agi_callington: 0 AGI Tx >> agi_callingtns: 0 AGI Tx >> agi_dnid: 333 AGI Tx >> agi_rdnis: unknown AGI Tx >> agi_context: incoming-agi-custom AGI Tx >> agi_extension: 333 AGI Tx >> agi_priority: 3 AGI Tx >> agi_enhanced: 0.0 AGI Tx >> agi_accountcode: AGI Tx >> AGI Rx << verbose "Failed to execute '/var/lib/asterisk/agi-bin/script.agi': No such file or directory" 2 == script.agi: Failed to execute '/var/lib/asterisk/agi-bin/script.agi': No such file or directory AGI Tx >> 200 result=1 == Auto fallthrough, channel 'SIP/210-082516b8' status is 'UNKNOWN'

I have to say that I’m using asterisk from trixbox on a vmware image. I created the script file in windows and with winscp transfered to the var/lib/asterisk/agi-bin/ directory. All other scripts have the owner asterisk, my script also has asterisk owner(changed manually because had root owner) and I put also chmod(0777)

This is my extension from extensions_custom.conf:

[incoming-agi-custom] exten => 333,1,Answer exten => 333,n,Background(main-menu) exten => 333,n,AGI(script.agi)

and this is my script.agi:

[code]#!/usr/bin/perl

use Asterisk::AGI;
use DBI;

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

Play “welcome.gsm”, greeting the caller

$AGI->stream_file(‘welcome’);

Play “product-code-prompt.gsm”, instructing the caller to enter the

product code, then allow ten seconds to enter four-digits

$pin = $AGI->get_data(‘main-menu’,10000,4);

$username = &quan_by_code($pin);

if ($username != 0) {
###$AGI->stream_file(‘there-are’);
$AGI->say_digits($username);
###$AGI->stream_file(‘available’);
} else {
###$AGI->stream_file(‘none-available’);
}

$AGI->stream_file(‘goodbye’);
$AGI->hangup;
exit;

sub quan_by_code {

Takes a product code as input, then returns the quantity available.

my $code = shift;
my $dbh = open_connection();
my $sql = “SELECT username FROM users WHERE pin=’$code’
LIMIT 1”;
my $sth = $dbh->prepare($sql);
$sth->execute or die “Unable to execute SQL query: $dbh->errstr\n”;
my $row = $sth->fetchrow_arrayref;
$sth->finish;
$dbh->disconnect;
if ( ($code == $row->[0]) && ($code != 0) ) {
return $row[1];
} else {
return 0;
}
}

sub open_connection {
my $dsn = “mysql:test:localhost:3306”;
my $username = ‘asteriskuser’;
my $password = ‘amp109’;

return DBI->connect(“DBI:$dsn”,$username,$password) or die $DBI::errstr;
}[/code]

Any idea why my script can’t be executed? at the start of the debug after executing “main-menu” it says Launched agi script /…/script.agi … :frowning: please help

After some search on net I found some tips:
I edited the script.agi and put #!/usr/bin/perl -w then chmod u+x script.agi

Problem now is it is returning 0 after script execution

-- Executing [333@incoming-agi-custom:1] Answer("SIP/210-08283e80", "") in new stack -- Executing [333@incoming-agi-custom:2] BackGround("SIP/210-08283e80", "main-menu") in new stack -- <SIP/210-08283e80> Playing 'main-menu' (language 'en') -- Executing [333@incoming-agi-custom:3] AGI("SIP/210-08283e80", "script.agi") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/script.agi AGI Tx >> agi_request: script.agi AGI Tx >> agi_channel: SIP/210-08283e80 AGI Tx >> agi_language: en AGI Tx >> agi_type: SIP AGI Tx >> agi_uniqueid: 1235576560.26 AGI Tx >> agi_callerid: 210 AGI Tx >> agi_calleridname: device AGI Tx >> agi_callingpres: 0 AGI Tx >> agi_callingani2: 0 AGI Tx >> agi_callington: 0 AGI Tx >> agi_callingtns: 0 AGI Tx >> agi_dnid: 333 AGI Tx >> agi_rdnis: unknown AGI Tx >> agi_context: incoming-agi-custom AGI Tx >> agi_extension: 333 AGI Tx >> agi_priority: 3 AGI Tx >> agi_enhanced: 0.0 AGI Tx >> agi_accountcode: AGI Tx >> -- AGI Script script.agi completed, returning 0 == Auto fallthrough, channel 'SIP/210-08283e80' status is 'UNKNOWN'
any idea?