Пожалуйста, войдите здесь. Часто задаваемые вопросы О нас
Задайте Ваш вопрос

Не работает AGI скрипт

1

Доброго дня, о великие гуру * ! :-)

Накалякал скрипт, запускаю и получаю Failed to execute '/var/lib/asterisk/agi-bin/crude1.php': Exec format error" 1

Подскажите в каком направлении рыть

Call-centre*CLI> 
      == Using SIP RTP TOS bits 184
      == Using SIP RTP CoS mark 5
        -- Executing [122@test_balance:1] Answer("SIP/5603-00000000", "") in new stack
        -- Executing [122@test_balance:2] AGI("SIP/5603-00000000", "crude1.php") in new stack
        -- Launched AGI Script /var/lib/asterisk/agi-bin/crude1.php
    <SIP/5603-00000000>AGI Tx >> agi_request: crude1.php
    <SIP/5603-00000000>AGI Tx >> agi_channel: SIP/5603-00000000
    <SIP/5603-00000000>AGI Tx >> agi_language: en
    <SIP/5603-00000000>AGI Tx >> agi_type: SIP
    <SIP/5603-00000000>AGI Tx >> agi_uniqueid: 1338806057.0
    <SIP/5603-00000000>AGI Tx >> agi_version: 1.8.11.0
    <SIP/5603-00000000>AGI Tx >> agi_callerid: 5603
    <SIP/5603-00000000>AGI Tx >> agi_calleridname: device
    <SIP/5603-00000000>AGI Tx >> agi_callingpres: 0
    <SIP/5603-00000000>AGI Tx >> agi_callingani2: 0
    <SIP/5603-00000000>AGI Tx >> agi_callington: 0
    <SIP/5603-00000000>AGI Tx >> agi_callingtns: 0
    <SIP/5603-00000000>AGI Tx >> agi_dnid: 122
    <SIP/5603-00000000>AGI Tx >> agi_rdnis: unknown
    <SIP/5603-00000000>AGI Tx >> agi_context: test_balance
    <SIP/5603-00000000>AGI Tx >> agi_extension: 122
    <SIP/5603-00000000>AGI Tx >> agi_priority: 2
    <SIP/5603-00000000>AGI Tx >> agi_enhanced: 0.0
    <SIP/5603-00000000>AGI Tx >> agi_accountcode: 
    <SIP/5603-00000000>AGI Tx >> agi_threadid: -1226949744
    <SIP/5603-00000000>AGI Tx >> 
    <SIP/5603-00000000>AGI Rx << verbose "Failed to execute '/var/lib/asterisk/agi-bin/crude1.php': Exec format error" 1
     crude1.php: Failed to execute '/var/lib/asterisk/agi-bin/crude1.php': Exec format error
    <SIP/5603-00000000>AGI Tx >> 200 result=1

Вот сам скриптик:

#!/usr/bin/php -q
<?php
require('phpagi.php');


global $agi;
$agi = new AGI();
$res=$agi->answer();

$cid = $agi->request["agi_callerid"];


$r=$agi->get_data('please-enter-your',14000,9);
$account_Number=$r['result'];

$balance=0;

$username = 'test';
$password = 'tester';

$client = new SoapClient(
    'https://192.168.0.1:443/services/abc/ClientDataService?wsdl',
    array('trace' => TRUE, 'style' => SOAP_RPC)
);

// Prepare SoapHeader parameters
$sh_param = new stdClass();
$sh_param->login = $username;
$sh_param->passhash = md5($password);


$headers = new SoapHeader('http://abc.ru/services/authentication/1.0', 'auth-token', $sh_param);

// Prepare Soap Client
$client->__setSoapHeaders(array($headers));

$balance='';

try { 
    $res = $client->getPersonData(array('request' => array('accountNumber' => $accountNumber)));
    echo $res->return->agreements->agreement->accounts->account->balance . "\n";


    $agi->stream_file('podogovoru');


    $agi->say_number($accountNumber);


    $agi->stream_file('balanssostavlyaet');

    $agi->say_money($balance);

        $s=$agi->get_data('returntomenu',9000,1);
        $st=$s['result'];


        if ($st=="*"){
        $agi->goto_dest('ivr-3');
        } else {

        $agi->hangup();
        }

} catch (SoapFault $fault) {
    //echo $client->__getLastRequest();
    //echo '\n---------------------------------------\n';
    //echo $client->__getLastResponse();

    $agi->stream_file('invalid');               
    $agi->hangup(); 
}

?>
удалить закрыть спам изменить тег редактировать

спросил 2012-06-05 05:27:11 +0400

nana_MeDBeD Gravatar nana_MeDBeD
312 46 11 34

Comments

Ну как бэ он тебе написал, что команда Exec неверно выполняется, но в скрипте ее нету, что странно...

switch ( 2012-06-05 08:19:35 +0400 )редактировать

Вот и я голову ломаю.......акромя agi set debug on как то можно дебажить agi скрипты ?

nana_MeDBeD ( 2012-06-05 11:00:48 +0400 )редактировать

4 Ответа

2

Попробуй chmod +x /var/lib/asterisk/agi-bin/crude1.php

ссылка удалить спам редактировать

ответил 2012-06-05 11:33:56 +0400

mik Gravatar mik
31 3 1 7
0

Упрости файл, попробуй пустой скрипт для начала. Версия * какая?

ссылка удалить спам редактировать

ответил 2012-06-05 13:33:10 +0400

Aven Gravatar Aven flag of Russian Federation
343 1 13
http://it-need.ru/
0

Короче трабла была в том, что скрипт был сохранен не в ANSI формате.

Но вылезло следующее :

-- Executing [122@test_balance:1] AGI("SIP/5603-00000001", "crude1.php") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/crude1.php
<SIP/5603-00000001>AGI Tx >> agi_request: crude1.php
<SIP/5603-00000001>AGI Tx >> agi_channel: SIP/5603-00000001
<SIP/5603-00000001>AGI Tx >> agi_language: en
<SIP/5603-00000001>AGI Tx >> agi_type: SIP
<SIP/5603-00000001>AGI Tx >> agi_uniqueid: 1338884606.1
<SIP/5603-00000001>AGI Tx >> agi_version: 1.8.11.0
<SIP/5603-00000001>AGI Tx >> agi_callerid: 5603
<SIP/5603-00000001>AGI Tx >> agi_calleridname: device
<SIP/5603-00000001>AGI Tx >> agi_callingpres: 0
<SIP/5603-00000001>AGI Tx >> agi_callingani2: 0
<SIP/5603-00000001>AGI Tx >> agi_callington: 0
<SIP/5603-00000001>AGI Tx >> agi_callingtns: 0
<SIP/5603-00000001>AGI Tx >> agi_dnid: 122
<SIP/5603-00000001>AGI Tx >> agi_rdnis: unknown
<SIP/5603-00000001>AGI Tx >> agi_context: test_balance
<SIP/5603-00000001>AGI Tx >> agi_extension: 122
<SIP/5603-00000001>AGI Tx >> agi_priority: 1
<SIP/5603-00000001>AGI Tx >> agi_enhanced: 0.0
<SIP/5603-00000001>AGI Tx >> agi_accountcode: 
<SIP/5603-00000001>AGI Tx >> agi_threadid: -1225966704
<SIP/5603-00000001>AGI Tx >> 
<SIP/5603-00000001>AGI Rx << Usage: php [options] [-f] <file> [--] [args...]
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<        php [options] -r <code> [--] [args...]
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<        php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<        php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<        php [options] -- [args...]
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<        php [options] -a
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx << 
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -a               Run interactively
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -c <path>|<file> Look for php.ini file in this directory
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -n               No php.ini file will be used
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -d foo[=bar]     Define INI entry foo with value 'bar'
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -e               Generate extended information for debugger/profiler
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -f <file>        Parse <file>.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -h               This help
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -i               PHP information
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -l               Syntax check only (lint)
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -m               Show compiled in modules
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -r <code>        Run PHP <code> without using script tags <?..?>
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -B <begin_code>  Run PHP <begin_code> before processing input lines
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -R <code>        Run PHP <code> for every input line
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -F <file>        Parse and execute <file> for every input line
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -E <end_code>    Run PHP <end_code> after processing all input lines
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -H               Hide any passed arguments from external tools.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -s               Display colour syntax highlighted source.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -v               Version number
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -w               Display source with stripped comments and whitespace.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   -z <file>        Load Zend extension <file>.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx << 
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   args...          Arguments passed to script. Use -- args when first argument
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<                    starts with - or script is read from stdin
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx << 
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   --rf <name>      Show information about function <name>.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   --rc <name>      Show information about class <name>.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx <<   --re <name>      Show information about extension <name>.
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
<SIP/5603-00000001>AGI Rx << 
<SIP/5603-00000001>AGI Tx >> 510 Invalid or unknown command
    -- <SIP/5603-00000001>AGI Script crude1.php completed, returning 0

Пошел за пистолетом...

ссылка удалить спам редактировать

ответил 2012-06-05 20:13:10 +0400

nana_MeDBeD Gravatar nana_MeDBeD
312 46 11 34

Comments

у вас сам скрипт выводит дебажные сообщение в консоль Астериска. вы неполный скрипт показали, нет подключении ваших классов.сложно что то сказать. уберите echo из скрипта.

brost ( 2012-06-06 10:27:49 +0400 )редактировать
0

Можно дебажить просто запуская их из консоли, но надо тогда сделать пхп скрипт исполняемым.

ссылка удалить спам редактировать

ответил 2012-06-05 11:08:10 +0400

switch Gravatar switch
8334 11 7 92
http://lynks.ru/

Comments

Он в любом случае должен быть исполняемым.

Aven ( 2012-06-05 13:32:13 +0400 )редактировать

Ваш ответ

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[скрыть предварительный просмотр]

Закладки и информация

Добавить закладку

подписаться на rss ленту новостей

Статистика

Задан: 2012-06-05 05:27:11 +0400

Просмотрен: 4,959 раз

Обновлен: Jun 05 '12

Проект компании "АТС Дизайн"
Asterisk® и Digium® являются зарегистрированными торговыми марками компании Digium, Inc., США.
IP АТС Asterisk распространяется под лицензией GNU GPL.