Dialplan Qustion

Hi,

im making a Dialplan to call 1 destination (my cellphone)
and i want it to call 10 seconds at a time with a different CID number (i have something like 100 numbers)

i have this dial plan that works :

[batchen-test]
exten => .,1,NoOp()
exten =>
.,n,Set(TIMEOUT(absolute)=10)
exten =>_.,n,Set(GLOBAL(NUMCID)=12345)
exten => _.,n,Set(CALLERID(num)=(${NUMCID}))
exten => _.,n,Set(CALLERID(name)=CallTest)
exten => _.,n,Verbose(1, Outgoing Caller ID: {$CALLERID(all)})
exten => _.,n,Dial(SIP/SomeTrunk/xxxxxxxxxx)
exten => h,1,Macro(hangupcall)

Now,
instead of making million rows of Set() and then another CID i want a GLOBAL or a script to run which will replace the CID every new call , every 10 seconds straight.

the GLOBAL i put in this dialplan works but i dont know how to make it with multiple data like :
exten =>.,n,Set(GLOBAL(NUMCID)=12345&123456&1234567) or exten =>.,n,Set(GLOBAL(NUMCID)=12345,12345,1234567)

Thanks

Can you explain why you need to send out anonymous calls (from another post of yours) at a rapid rate? It sounds like spamming, and I doubt too many people here would be interested in helping.

Hi,

Not anonymous !
as i said i have 100 DID numbers ()From a provider) and im going to call 1 number - my cellphone
we want to check all of ours Outbound that they are working -no spaming!!!

OK, then you’ll probably just want to use call files. Write a php/perl/etc script to create the call file reading the DID from a database or a text file, then sleep for 10 seconds before creating the next file.

yea - but how ?
how do i make a script that replace the CID - exten => _.,n,Set(CALLERID(num)=)
i dont unsderstand how to do it.

i need it to be diffrent number each time but one by one,
for example :

NUMBER= 445555555 , 442222222, 447777777 etc

can you give m an example please ?

Using php, it would be something like this…
It will be in a loop, and you’d just set the variables each time.

                $fh = fopen("/var/spool/asterisk/callfile_name", 'w');
                    fwrite($fh, "Channel: SIP/$number_to_dial@$some_trunk\n");
                    fwrite($fh, "Context: batchen-test\n");
                    fwrite($fh, "Extension: s\n");
                    fwrite($fh, "Priority: 1\n");
                    fwrite($fh, "SetVar: id=$id\n"); //If necessary to pass other variables
                    fwrite($fh, "Set: __SIPADDHEADER1=X-ASTCID:$next_caller_id_number\n");    
                fclose($fh);
            
                rename("/var/spool/asterisk/callfile_name", "/var/spool/asterisk/outgoing/callfile_name");
1 Like

i dont know PHP can you do it in bash ?
and show me what to put in my dialplan to connect the script ?

sorry im new to this

There is a plethora of Asterisk call files out there on the web. Some examples:

And that’s just a few of the top hits from Google.

While I appreciate that you’re new to Asterisk, doing some research and testing some things out is part of the learning process. Simply asking someone to create the dialplan and scripts for you is not going to get you far, nor allow you to administer and run your system in an effective fashion.

1 Like

Thanks you But i did a Research before coming here, i dont think i need a script and i do think my question can be simple

as i continue testing i found a half solution :

[batchen-test]
exten => .,1,NoOp()
exten =>
.,n,Set(TIMEOUT(absolute)=10)
exten => _.,n,Set(NUMCID=${FILE(/home/num.txt,int)})
exten => _.,n,Set(CALLERID(num)=(${NUMCID}))
exten => _.,n,Set(CALLERID(name)=CallTest)
exten => _.,n,Dial(SIP/SomeTrunk/xxxxxxx)
exten => h,1,Macro(hangupcall)

it does take the varible NUMCID from the file /home/num.txt
but i need it to take one by one

it either talk all (if i write the numbers in 1 row) or only the first number (if i write the numbers one by one in lines)
is there a way to make it take one by one each loop ?

thanks you for the documentation but i know dial plan and i, not new to asterisk so it does not answer my specific qustion
and i know bash too pretty well i just dont understand how to pass 100 numbers in loop to my dialplan.

i hope you can help me.

I’m not sure how you’re triggering this context to be run, that’s why I had suggested using a call file. If you’re comfortable with creating bash scripts, you only need to create an output text file with the data in my last post…

Channel: SIP/$number_to_dial@$some_trunk\n
Context: batchen-test\n
Extension: s\n
Priority: 1\n"
SetVar: id=$id\n //If necessary to pass other variables
Set: __SIPADDHEADER1=X-ASTCID:$next_caller_id_number\n

You’ll do that in the bash script by reading the file, line by line, and creating the call file and put the caller id in the last line in place of the variable. Save the call file, and move it to /var/spool/asterisk/outgoing/. Have the script sleep for 10 seconds, then create the next call file.

The dialplan only needs to dial the number (your cell phone)
[bratchen-test]
exten => s,1,Dial(SIP/yournumber@trunk,20)
same => n,Hangup()

If you wish to do this using dialplan then have something like this
(1)Read all CLIs from file. (You are already doing this using FILE)
(2)Get total number of CLIs (Hint: FIELDQTY https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_FIELDQTY )
(3)Loop through each CLI (HInt: While,EndWhile https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_While)
(3.1) Set new CLI as Callerid (HInt: Callerid(num) https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_CALLERID)
(3.2) Dial the number (Hint: Dial with options g, L or S https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Dial)

Weather you are using AMI or callfile to execute the steps in your dialplan, make sure to set proper value for timeout

–Satish