linux - How to do some task after Asterisk ReceiveFax function calling? -
i have asterisk server installed: , have created dial-plan receive fax: want task after received fax. but, line written after recevefax
function called when transmission failed. if transmission success never called line after.
my dial-plan:
;######################### fax dialplan implementation start ########################## exten => _15555551212,1,noop(fax receiving ${exten}) exten => _15555551212,n,answer exten => _15555551212,n,ringing exten => _15555551212,n,macro(inboundfax) exten => _15555551212,n,noop(done) exten => h,1, noop(completed...) [macro-inboundfax] exten => s,1,noop(**** fax received ${callerid(num)} ${strftime(${epoch},,%c)} ****) exten => s,n,set(faxopt(ecm)=yes) exten => s,n,set(filename=fax-${strftime(${epoch},,%y%m%d-%h%m%s)}) exten => s,n,set(faxfile=${filename}.tif) exten => s,n,set(faxopt(ecm)=yes) exten => s,n,set(faxopt(headerinfo)=received mycompany ${strftime(${epoch},,%y-%m-%d %h:%m)}) exten => s,n,set(faxopt(localstationid)=5555551212) exten => s,n,set(faxopt(maxrate)=14400) exten => s,n,set(faxopt(minrate)=4800) exten => s,n,noop(faxopt(ecm) : ${faxopt(ecm)}) exten => s,n,noop(faxopt(headerinfo) : ${faxopt(headerinfo)}) exten => s,n,noop(faxopt(localstationid) : ${faxopt(localstationid)}) exten => s,n,noop(faxopt(maxrate) : ${faxopt(maxrate)}) exten => s,n,noop(faxopt(minrate) : ${faxopt(minrate)}) exten => s,n,noop(**** receiving fax : ${faxfile} ****) exten => s,n,set(fax_dest=/var/www/html/private/fax/received) exten => s,n,set(faxdest=/tmp) exten => s,n,dumpchan(3) exten => s,n,receivefax(${faxdest}/${faxfile}) exten => s,n,verbose(3,- fax receipt completed status: ${faxstatus}) exten => s,n,verbose(fax receipt completed status: ${faxstatus}) exten => s,n,verbose(faxfile moving... ${faxdest}/${faxfile} -> ${fax_dest}/) exten => s,n,system(mv ${faxdest}/${faxfile} ${fax_dest}/) exten => s,n,verbose(fax file moved.) exten => s,n,noop(mail sending...) ;exten => s,n,system(echo | mutt -a ${faxdest}/${faxfile} -s "received fax" testfax@gmail.com) exten => s,n,noop(mail sent)
console log: (while receiving fax)
== using sip rtp cos mark 5 -- executing [15555551212@from-sip:1] noop("sip/4001-0000000f", "fax receiving 15555551212") in new stack -- executing [15555551212@from-sip:2] answer("sip/4001-0000000f", "") in new stack -- executing [15555551212@from-sip:3] ringing("sip/4001-0000000f", "") in new stack -- executing [15555551212@from-sip:4] macro("sip/4001-0000000f", "inboundfax") in new stack -- executing [s@macro-inboundfax:1] noop("sip/4001-0000000f", "**** fax received 4001 sat jun 20 15:25:22 2015 ****") in new stack -- executing [s@macro-inboundfax:2] set("sip/4001-0000000f", "faxopt(ecm)=yes") in new stack -- executing [s@macro-inboundfax:3] set("sip/4001-0000000f", "filename=fax-20150620-152522") in new stack -- executing [s@macro-inboundfax:4] set("sip/4001-0000000f", "faxfile=fax-20150620-152522.tif") in new stack -- executing [s@macro-inboundfax:5] set("sip/4001-0000000f", "faxopt(ecm)=yes") in new stack -- executing [s@macro-inboundfax:6] set("sip/4001-0000000f", "faxopt(headerinfo)=received mycompany 2015-06-20 15:25") in new stack -- executing [s@macro-inboundfax:7] set("sip/4001-0000000f", "faxopt(localstationid)=5555551212") in new stack -- executing [s@macro-inboundfax:8] set("sip/4001-0000000f", "faxopt(maxrate)=14400") in new stack -- executing [s@macro-inboundfax:9] set("sip/4001-0000000f", "faxopt(minrate)=4800") in new stack -- executing [s@macro-inboundfax:10] noop("sip/4001-0000000f", "faxopt(ecm) : yes") in new stack -- executing [s@macro-inboundfax:11] noop("sip/4001-0000000f", "faxopt(headerinfo) : received mycompany 2015-06-20 15:25") in new stack -- executing [s@macro-inboundfax:12] noop("sip/4001-0000000f", "faxopt(localstationid) : 5555551212") in new stack -- executing [s@macro-inboundfax:13] noop("sip/4001-0000000f", "faxopt(maxrate) : 14400") in new stack -- executing [s@macro-inboundfax:14] noop("sip/4001-0000000f", "faxopt(minrate) : 4800") in new stack -- executing [s@macro-inboundfax:15] noop("sip/4001-0000000f", "**** receiving fax : fax-20150620-152522.tif ****") in new stack -- executing [s@macro-inboundfax:16] set("sip/4001-0000000f", "fax_dest=/var/www/html/private/fax/received") in new stack -- executing [s@macro-inboundfax:17] set("sip/4001-0000000f", "faxdest=/tmp") in new stack -- executing [s@macro-inboundfax:18] dumpchan("sip/4001-0000000f", "3") in new stack -- -- dumping info channel: sip/4001-0000000f: -- ================================================================================ -- info: -- name= sip/4001-0000000f -- type= sip -- uniqueid= 1434794122.15 -- linkedid= 1434794122.15 -- calleridnum= 4001 -- calleridname= faxvoip softphone -- connectedlineidnum= (n/a) -- connectedlineidname=(n/a) -- dniddigits= 15555551212 -- rdnis= (n/a) -- parkinglot= default -- language= en -- state= (6) -- rings= 0 -- nativeformat= (ulaw) -- writeformat= slin -- readformat= ulaw -- rawwriteformat= ulaw -- rawreadformat= ulaw -- writetranscode= yes (slin)->(ulaw) -- readtranscode= no -- 1stfiledescriptor= 26 -- framesin= 1 -- framesout= 0 -- timetohangup= 0 -- elapsedtime= 0h0m0s -- directbridge= <none> -- indirectbridge= <none> -- context= macro-inboundfax -- extension= s -- priority= 18 -- callgroup= -- pickupgroup= -- application= dumpchan -- data= 3 -- blocking_in= (not blocking) -- -- variables: -- macro_depth=1 -- faxdest=/tmp -- fax_dest=/var/www/html/private/fax/received -- faxfile=fax-20150620-152522.tif -- filename=fax-20150620-152522 -- macro_priority=4 -- macro_context=from-sip -- macro_exten=15555551212 -- sipcallid=af6dfc5a-ee0f-1910-9de1-e06995d7f913@dsk-388 -- sipdomain=xx.xx.xx.xx -- sipuri=sip:4001@xx.xx.xx.xx:5065 -- ================================================================================ -- executing [s@macro-inboundfax:19] receivefax("sip/4001-0000000f", "/tmp/fax-20150620-152522.tif") in new stack -- channel 'sip/4001-0000000f' receiving fax '/tmp/fax-20150620-152522.tif' == using udptl cos mark 5 -- channel 'sip/4001-0000000f' fax session '5' started -- fax handle 0: [ 026.931800 ], entering closing state -- fax handle 0: [ 026.931866 ], entering closing state -- channel 'sip/4001-0000000f' fax session '5' complete, result: 'success' (fax_success), error: 'no_error', pages: 2, resolution: '204x98', transfer rate: '14400', remotesid: '' == spawn extension (macro-inboundfax, s, 19) exited non-zero on 'sip/4001-0000000f' in macro 'inboundfax' == spawn extension (from-sip, 15555551212, 4) exited non-zero on 'sip/4001-0000000f'
[fax-rx] exten => _x.,1,ringing() exten => _x.,n,answer() exten => _x.,n,wait(10) exten => fax,1,verbose(got fax on ${exten}) exten => fax,n,noop(**** fax receive ****) exten => fax,n,set(global(faxcount)=$[ ${global(faxcount)} + 1 ]) exten => fax,n,set(faxcount=${global(faxcount)}) exten => fax,n,set(faxfile=fax-${faxcount}-rx.tif) exten => fax,n,set(global(lastfaxcallernum)=${callerid(num)}) exten => fax,n,set(global(lastfaxcallername)=${callerid(name)}) exten => fax,n,noop(**** setting faxopt ****) exten => fax,n,set(faxopt(ecm)=yes) exten => fax,n,set(faxopt(headerinfo)=my faxback rx) exten => fax,n,set(faxopt(localstationid)=1234567890) exten => fax,n,set(faxopt(maxrate)=14400) exten => fax,n,set(faxopt(minrate)=2400) exten => fax,n,noop(faxopt(ecm) : ${faxopt(ecm)}) exten => fax,n,noop(faxopt(headerinfo) : ${faxopt(headerinfo)}) exten => fax,n,noop(faxopt(localstationid) : ${faxopt(localstationid)}) exten => fax,n,noop(faxopt(maxrate) : ${faxopt(maxrate)}) exten => fax,n,noop(faxopt(minrate) : ${faxopt(minrate)}) exten => fax,n,noop(**** receiving fax : ${faxfile} ****) exten => fax,n,receivefax(/var/spool/asterisk/fax/${faxfile}) ; hangup! print faxopts exten => h,1,noop(faxopt(ecm) : ${faxopt(ecm)}) exten => h,n,noop(faxopt(filename) : ${faxopt(filename)}) exten => h,n,noop(faxopt(headerinfo) : ${faxopt(headerinfo)}) exten => h,n,noop(faxopt(localstationid) : ${faxopt(localstationid)}) exten => h,n,noop(faxopt(maxrate) : ${faxopt(maxrate)}) exten => h,n,noop(faxopt(minrate) : ${faxopt(minrate)}) exten => h,n,noop(faxopt(pages) : ${faxopt(pages)}) exten => h,n,noop(faxopt(rate) : ${faxopt(rate)}) exten => h,n,noop(faxopt(remotestationid) : ${faxopt(remotestationid)}) exten => h,n,noop(faxopt(resolution) : ${faxopt(resolution)}) exten => h,n,noop(faxopt(status) : ${faxopt(status)}) exten => h,n,noop(faxopt(statusstr) : ${faxopt(statusstr)}) exten => h,n,noop(faxopt(error) : ${faxopt(error)})
Comments
Post a Comment