Кусок диалплана:
Код: Выделить всё
exten => 1234,1,Answer
same => n,AGI(clients.sh,${CALLERID(num)})
same => n,NoOp(Result_1: ${res1})
same => n,HangUp
Код: Выделить всё
#!/bin/bash
RESULT1=$(echo "SELECT client FROM test WHERE number=$1" | mysql -uroot -pParoLL clients | tail -1)
echo -n -e "SET VARIABLE res1 ${RESULT1}"
Код: Выделить всё
-- Executing [1234@family:1] Answer("SIP/1001-00000006", "") in new stack
-- Executing [1234@family:2] AGI("SIP/1001-00000006", "clients.sh,1001") in new stack
-- Launched AGI Script /usr/share/asterisk/agi-bin/clients.sh
<SIP/1001-00000006>AGI Tx >> agi_request: clients.sh
<SIP/1001-00000006>AGI Tx >> agi_channel: SIP/1001-00000006
<SIP/1001-00000006>AGI Tx >> agi_language: ru
<SIP/1001-00000006>AGI Tx >> agi_type: SIP
<SIP/1001-00000006>AGI Tx >> agi_uniqueid: 1461048211.6
<SIP/1001-00000006>AGI Tx >> agi_version: 1.8.32.3
<SIP/1001-00000006>AGI Tx >> agi_callerid: 1001
<SIP/1001-00000006>AGI Tx >> agi_calleridname: Test
<SIP/1001-00000006>AGI Tx >> agi_callingpres: 0
<SIP/1001-00000006>AGI Tx >> agi_callingani2: 0
<SIP/1001-00000006>AGI Tx >> agi_callington: 0
<SIP/1001-00000006>AGI Tx >> agi_callingtns: 0
<SIP/1001-00000006>AGI Tx >> agi_dnid: 1234
<SIP/1001-00000006>AGI Tx >> agi_rdnis: unknown
<SIP/1001-00000006>AGI Tx >> agi_context: family
<SIP/1001-00000006>AGI Tx >> agi_extension: 1234
<SIP/1001-00000006>AGI Tx >> agi_priority: 3
<SIP/1001-00000006>AGI Tx >> agi_enhanced: 0.0
<SIP/1001-00000006>AGI Tx >> agi_accountcode:
<SIP/1001-00000006>AGI Tx >> agi_threadid: 140469556406016
<SIP/1001-00000006>AGI Tx >> agi_arg_1: 1001
<SIP/1001-00000006>AGI Tx >>
<SIP/1001-00000006>AGI Rx << SET VARIABLE res1 Иванов Иван
<SIP/1001-00000006>AGI Tx >> 200 result=1
[Apr 19 09:43:31] ERROR[4220]: utils.c:1343 ast_carefulwrite: write() returned error: Broken pipe
-- <SIP/1001-00000006>AGI Script clients.sh completed, returning 0
-- Executing [1234@family:3] NoOp("SIP/1001-00000006", "Result_1: Иванов") in new stack
-- Executing [1234@family:4] Hangup("SIP/1001-00000006", "") in new stack
== Spawn extension (family, 1234, 4) exited non-zero on 'SIP/1001-00000006'