Hi i have asterisk 11 .
i want a custom dial plan that will read Caller IDs from external file in /root/cid.txt
now i have the dial plan works fine when the CIDs i put them my self in the custom file .as below :
[ahmad]
exten => s,1,NoOp(Context : ${CONTEXT} : “Heyyyyy you are in custom”)
exten => s,n,GotoIf($["${CALLERID(num)}" = “2832930”]?next:end)
exten => s,n,GotoIf($["${CALLERID(num)}" = “2832940”]?next:end)
exten => s,n,GotoIf($["${CALLERID(num)}" = “2832950”]?next:end)
exten => s,n,GotoIf($["${CALLERID(num)}" = “2832960”]?next:end)
exten => s,n(next),goto(from-internal,30,1)
exten => s,n(end),system(echo “${DATETIME} - ${CALLERID} - ${CHANNEL}” >> /var/log/asterisk/calls)
as we see i put the CID myself —> 2832930" ,2832940 2832940 2832950 28329360.
so what i need is i want to create a file /root/cid.txt that will be updated dynamically from outside .
and i want to have a for loop or while loop in asterisk that will sweep all the lines line by line and create the rules automatically .
so if there was 1 line in the file /var/log/asterisk/calls with 1 CID like 123456
my dial plan should be equivalent to below :
[ahmad]
exten => s,1,NoOp(Context : ${CONTEXT} : “Heyyyyy you are in custom”)
exten => s,n,GotoIf($["${CALLERID(num)}" = “123456”]?next:end)
exten => s,n(next),goto(from-internal,30,1)
exten => s,n(end),system(echo “${DATETIME} - ${CALLERID} - ${CHANNEL}” >> /var/log/asterisk/calls)
if i had 2 CID ( 2 lines in the file/var/log/asterisk/calls) —> , 123456 & 123455 , then it should be equivalent to
[ahmad]
exten => s,1,NoOp(Context : ${CONTEXT} : “Heyyyyy you are in custom”)
exten => s,n,GotoIf($["${CALLERID(num)}" = “123456”]?next:end)
exten => s,n,GotoIf($["${CALLERID(num)}" = “123455”]?next:end)
exten => s,n(next),goto(from-internal,30,1)
exten => s,n(end),system(echo “${DATETIME} - ${CALLERID} - ${CHANNEL}” >> /var/log/asterisk/calls)
so again
all i need is just replace adding the CID rules with 1 single rule that will automatically sweep the external file lines.
thank you