Asterisk return value to external file

say that there is a call and working into a context .
i want to add some rules inside the dial plan to extract some asterisk variables like CID , DID to external file .

say there was a call .

i want to do like echo $CID or echo $DID >> /root/something.txt

i searched for many functions on asterisk but didn’t know how to start .

i did find some function that can take variable outside from asterisk into asterisk

but not from asterisk to outside

as example :slight_smile:exten => 3333,1,Set(result=${shell(/root/})
exten => 3333,2,Verbose(result is: ${result})
this run bash from outside and get variable inside the context .

but what i need is that , i want to extract some parameters say like DID , CID & destination # being called to a file in the path /root/something

say an incoming call from 111111 with DID 2222hit my system ,
next call was from 333333 dialing my DID 2222 , i want to add other line like 33333,222

and so on …

i want to have in the file /root/something the contents like
111111 , 2222

any help would be very thankful

thank you

You should look at AGI, but the first one is the System() application and the second one is the ${SHELL()} function.

thank you david
i tried to have function of time/date & destination # being called but there are blank !!

my dial plan —>exten => s,n(next),system(echo " ${DATETIME}- ${EXTEN} - ${CALLERID(all)} - ${CHANNEL}" >>

cat /var/log/asterisk/calls

  • s - 2832111 <2832111> - DAHDI/i1/2832930-bb4

as you see …i have date as blank !!

my asterisk version is 11
Asterisk 11.21.0, Copyright (C) 1999 - 2013 Digium, Inc. and others.

any help ?

thank you

Here you have a quick sample using system

exten=>h,1,System(echo Destination “${CDR(dst)} | hangupcause ${HANGUPCAUSE} | dialstatus ${DIALSTATUS} | date ${STRFTIME(${EPOCH},%Y-%m-%d_%H-%M-%S)}” >>/var/www/callstatus.txt)

Guys , thank you all
worked with me finally