forked from jefaokpta/AGI-Shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AGI-shell.sh
74 lines (61 loc) · 1.87 KB
/
AGI-shell.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
conect="mysql -uroot -pjefao -e"
declare -a array
while read -e ARG && [ "$ARG" ] ; do
array=(` echo $ARG | sed -e 's/://'`)
export ${array[0]}=${array[1]}
done
# Recebendo Variaveis do Asterisk no lancamento
echo $agi_request >&2
echo $agi_channel >&2
echo $agi_language >&2
echo $agi_type >&2
echo $agi_uniqueid >&2
echo $agi_callerid >&2
echo $agi_dnid >&2
echo $agi_rdnis >&2
echo $agi_context >&2
echo $agi_extension >&2
echo $agi_priority >&2
echo $agi_enhanced >&2
checkresults() {
while read line
do
case ${line:0:4} in
"200 " ) echo $line >&2
return;;
"510 " ) echo $line >&2
return;;
"520 " ) echo $line >&2
return;;
* ) echo $line >&2;; #Continua lendo ate um possivel erro
#Tipo um "520 End ..."
esac
done
}
sql=(`$conect "SELECT password FROM VipReal.peers WHERE name = $agi_callerid"`)
pass=${sql[1]}
echo "1. Testando Playback ..." >&2
echo "STREAM FILE beep \"\""
checkresults
echo "2. Mandando texto pro canal ..." >&2
echo "send text \"que\ bruxaria\ essa?\""
checkresults
echo "3. Setando variavel ..." >&2
echo "set variable \"CHANNEL(language)\" pt_BR"
checkresults
echo "4. Testando 'saynumber' ..." >&2
echo "SAY NUMBER $agi_extension \"\""
checkresults
echo "5. Setando variavel ..." >&2
echo "set variable Bla $pass"
checkresults
echo "6. Testando 'say phonetic' ..." >&2
echo "say phonetic gsm \"\""
checkresults
echo "6a. playback" >&2
echo "STREAM FILE tt-monkeys \"\" "
checkresults
echo "" >&2
echo "verbose $1"
checkresults