Where to put code
I've been investigating the following for quite some time with no luck.
I'm trying to execute the following Unix command on all out going and incoming calls:-
For incoming calls:-
exten => s, n, system(echo "IN#${CALLERID(name)} #${CALLERID(number #${UNIQUEID}" > /tmp/panels/cid/${UNIQUEID})
For outgoing calls:-
exten => s, n, system(echo "OUT##${EXTEN}#${UNIQUEID}" > /tmp/panels/cid/${UNIQUEID})
The reason why I want to do this is so that I can track the specified directory from my website(which is permanently open) in order to identify calls and store them on my system.
This process does however go further than the asterisk MySQL call storage facility has to offer.
Any help would be appreciated. I am of course open to other suggestions and or questions.
Thanks,
Shane James
OUTBOUND:
open up extensions.conf
goto the context
[macro-dialout-trunk]
scroll down and find the two lines, and insert your code BETWEEN those lines.
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
INBOUND (Please test this piece extra carefully)
goto the context
[from-pstn]
DIRECTLY underneath that heading insert your code as:
exten => _X.,1,system(echo "IN#${CALLERID(name)} #${CALLERID(number)} #${UNIQUEID}" > /tmp/panels/cid/${UNIQUEID})
Save changes,
reload config
test.
I don't recall AMP/FreePBX ever overwriting extensions.conf. Even in an upgrade i don't recall it happening. I know it has changed between trixbox builds, (which is why you always keep notes about modifications you make and do regression testing when you do updates ;) )
Day to day normal FreePBX administration, I've never seen it happen (although would be interested in knowing if it can be done...add a 'what not to do' to my list)
Ok, let's play around with OUTGOING first. Here is the EXACT code for that put where you told me to put it under [macro-dialout-trunk]
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,system(/bin/echo "bleh" > /tmp/bleh);
exten => s,n,system(echo "OUT##${EXTEN}#${UNIQUEID}" > /tmp/panels/cid/${UNIQUEID})
I don't know if this will help your understanding of my setup a bit more, but I have 4 trunks configured using mISDN and I've set the outgoing route which is 0|. to use 2 of the 4 trunks as 2 of them are offline for the time being.
I believe I've got outgoing working correctly:-
exten => s,n(customtrunk),Set(pre_num=${CUT(OUT_${DIAL_TRUNK},$,1)})
exten => s,n,Set(the_num=${CUT(OUT_${DIAL_TRUNK},$,2)}) ; this is where we expect to find string OUTNUM
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,system(/bin/echo "OUT##${OUTNUM}#${UNIQUEID}" > /tmp/${UNIQUEID})
exten => s,n,GotoIf($["${the_num}" = "OUTNUM"]?outnum:skipoutnum) ; if we didn't find "OUTNUM", then skip to Dial
exten => s,n(outnum),Set(the_num=${OUTNUM}) ; replace "OUTNUM" with the actual number to dial
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
Let me know if that's the correct way of doing it? Now onto INCOMING, any ideas?
Anyway that gets the job done is correct!
Looks like its all good.
Now inbound. I'm not familiar with the mISDN system...but I'm assuming that it uses the same contexts for other inbound calls from telcos. If you put the bit of code in below, and place a test call, does it show up in the live log ( asterisk -cvvvvvvr )
[from-pstn]
DIRECTLY underneath that heading insert your code as:
exten => _X.,1,NoOp(&&&&&&&&&&&& INBOUND TEST &&&&&&&&&&&&&&&)
save, reload config
place test call.
(Does the above "&&&&&&& INBOUND TEST &&&&&" statement show up in the live log)
If it does, then this is where you would want to put the code in. It should be the basic same line that you had put in for your outbound. It works on my systems 2.2.X and 2.4
I don't recall AMP/FreePBX ever overwriting extensions.conf. Even in an upgrade i don't recall it happening.
I have to re-order some stuff in extensions.conf because of some hacks I made. Every time I upgrade the core module of freepbx it overwrites extensions.conf, and then I have to go re-order everything again.

Member Since:
2008-01-11