Dear man :
I have a case to demo for DID call out :
Because I am junior in asterisk dialplan AGI .
I don’t know what’s difference system() or agi() in dialpaln .
I use a agi shell script (iptone.sh) to do this job ,
I need choice from user name to decide his(or her) call out number .
First : I change dialplan as following to import dialplan variance CALLERID(name) to shell script
exten => _2NXXXXXXX,n,agi(iptone.sh,"${CALLERID(name)}")
exten => _2NXXXXXXX,n,agi([agi://127.0.0.1:5100/setOutboundCallerI ... runkId=108](agi://127.0.0.1:5100/setOutboundCallerId.agi?trunkId=108))
exten => _2NXXXXXXX,n,NoOp(CALLERID(num): $NUM)
it’s ok , and my shell script is work ,
iptone.sh
#!/bin/bash
Program:
Using username to assign callerID num.
History:
2014/12/25 JJChiou four release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
NAME="$1"
set NUM:
NUM=abc123
echo " my name is $NAME " > /tmp/var.txt
case “$NAME” in
ceo*) NUM=07010994411 ;;
boss*) NUM=07010994412 ;;
dayze*) NUM=07010994415 ;;
kevin*) NUM=07010994418 ;;
ava*) NUM=07010994419 ;;
carol*) NUM=07010994414 ;;
leo*) NUM=07010994422 ;;
vincent*) NUM=07010994421 ;;
gary*) NUM=07010994417 ;;
kt*) NUM=07010994413 ;;
service*) NUM=07010994416 ;;
*) NUM=07010994410 ;;
esac
Get NUM:
echo " my number is $NUM " >> /tmp/var.txt
export NUM
as I can see it work like as ;
#cat /tmp/var.txt
my name is leo.104.mobile
my number is 07010994422
How can I export the variance NUM to replace variance CALLERID(num) in dialplan ?
Thanks
Best Regard
JJ.Chiou
I suppose, you want to set a dynamic callerid num based on the value of the ${CaLLERID(name)} variable.
There are many easier ways to do this …
1- Using GotoIf and Set(CALLERID(num)=${mycallerid}).
2-Using localchannel.
3- Using ExecIf and Set(CALLERID(num)=${mycallerid}).
Thanks your reply .
Your idea is right , RD will do it if the service is formed announced .
But first , RD customize the system , same user can login from hardphone , desktop , or mobile .
So same user account will has several CALLEDED(name), I just need to demo the DID call out function to customer . So I use shell script to choice CALLERID(num) from cllerid(name) . I do the function in shell script , but I need to bring the variance to dialplan and replace original callered(num) .
Does any idea about to do it ?
Im not sure, and I havent test it with a bash script… But I think you can use SHELL() function to execute your script, this function Executes a command using the system shell and captures its output.
example:
exten => 4002,1,Answer
exten => 4002,n,Set(RESULT=${SHELL(date +%s)})
exten => 4002,n,NoOp(${RESULT})
exten => 4002,n,Hangup
Thanks your opion, but the url tell us "If you need to return a specific value (string) to the dialplan then use either AGI or SHELL as introduced in Asterisk 1.6.0."
voip-info.org/wiki/view/Asterisk+cmd+System
Since not any parameter to the shell script .
ear all :
I solved the problem :
voip-info.org/wiki/view/Asterisk+AGI
the default asterisk let 16 parameter from dialplan to agi ,
first : I import CALLERID(name) to shell script .
second :
#!/bin/bash
Program:
Using username to assign callerID num.
History:
2014/12/25 JJChiou four release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
Name="$1"
set NUM:
NUM=abc123
#echo " my name is $Name " > /tmp/var.txt
case “$Name” in
ceo*) NUM=07010994411 ;;
boss*) NUM=07010994412 ;;
dayze*) NUM=07010994415 ;;
kevin*) NUM=07010994418 ;;
ava*) NUM=07010994419 ;;
carol*) NUM=07010994414 ;;
leo*) NUM=07010994422 ;;
vincent*) NUM=07010994421 ;;
gary*) NUM=07010994417 ;;
kt*) NUM=07010994413 ;;
service*) NUM=07010994416 ;;
*) NUM=07010994410 ;;
esac
Get NUM:
echo “SET CALLERID “$CIDNAME”<$NUM>”
the parameter CALLERID(num) is carry to dialplan .