[AsteriskBrasil] AGI - Shell Script

Carlos Eduardo B. Rovaris carlosrovaris em gmail.com
Terça Maio 29 22:13:20 BRT 2012


Boa noite,


Gostaria de saber se alguém tem AGI em desenvolvida em Shell Script que 
poderia me auxiliar em alguns pontos que estou com dificuldades de resolver.


Segue minha configuração:

->>>> Extensions.conf

exten => 500,1,agi(2test.sh)
exten => 500,n,NoOP(${consulta})

############################################################

->>>> Script Shell:

#!/bin/bash

numero=48xxxxxxxx

consulta=  ## procedimento de consulta do valor armazenado na variavel 
numero ##

echo "SET VARIABLE consulta $consulta "

############################################################

->>>> Debug Asterisk console:

Verbosity is at least 20
   == Using SIP RTP CoS mark 5
     -- Executing [500 em external:1] AGI("SIP/1600-00000038", "2test.sh") 
in new stack
     -- Launched AGI Script /var/lib/asterisk/agi-bin/2test.sh
<SIP/1600-00000038>AGI Tx >> agi_request: 2test.sh
<SIP/1600-00000038>AGI Tx >> agi_channel: SIP/1600-00000038
<SIP/1600-00000038>AGI Tx >> agi_language: en
<SIP/1600-00000038>AGI Tx >> agi_type: SIP
<SIP/1600-00000038>AGI Tx >> agi_uniqueid: 1338338846.56
<SIP/1600-00000038>AGI Tx >> agi_version: 1.8.12.0
<SIP/1600-00000038>AGI Tx >> agi_callerid: 1600
<SIP/1600-00000038>AGI Tx >> agi_calleridname: CEBR2
<SIP/1600-00000038>AGI Tx >> agi_callingpres: 0
<SIP/1600-00000038>AGI Tx >> agi_callingani2: 0
<SIP/1600-00000038>AGI Tx >> agi_callington: 0
<SIP/1600-00000038>AGI Tx >> agi_callingtns: 0
<SIP/1600-00000038>AGI Tx >> agi_dnid: 500
<SIP/1600-00000038>AGI Tx >> agi_rdnis: unknown
<SIP/1600-00000038>AGI Tx >> agi_context: external
<SIP/1600-00000038>AGI Tx >> agi_extension: 500
<SIP/1600-00000038>AGI Tx >> agi_priority: 1
<SIP/1600-00000038>AGI Tx >> agi_enhanced: 0.0
<SIP/1600-00000038>AGI Tx >> agi_accountcode:
<SIP/1600-00000038>AGI Tx >> agi_threadid: 1095186752
<SIP/1600-00000038>AGI Tx >>
<SIP/1600-00000038>AGI Rx << SET VARIABLE consulta 5
<SIP/1600-00000038>AGI Tx >> 200 result=1
[May 30 04:47:28] ERROR[14217]: utils.c:1164 ast_carefulwrite: write() 
returned error: Broken pipe
     -- <SIP/1600-00000038>AGI Script 2test.sh completed, returning 0
     -- Executing [500 em external:2] NoOp("SIP/1600-00000038", "5") in new 
stack
     -- Auto fallthrough, channel 'SIP/1600-00000038' status is 'UNKNOWN'
server*CLI>

############################################################

Basicamente o que estou precisando resolver:
- como armazenar o valor da "agi_extension" na variavel "numero" do 
Shell Script ?

- Como faço para encaminhar a chamada de acordo com o valor de retorno 
da AGI ?

ex: No exemplo do log, disquei 500, e através da AGI retornou o valor "5".

Assim gostaria de fazer:

Caso o valor seja "4", encaminha para Trunk1
Caso o valor seja "5", encaminha para Trunk2
Caso o valor seja "6", encaminha para Trunk3


Agradeço toda e qualquer ajuda.



Mais detalhes sobre a lista de discussão AsteriskBrasil