Careful running system commands from dialplan (on a remote system in this case), or you can create a fork bomb if you allow enough calls into that rule quickly enough. On 25 March 2018 at 12:39, Morteza Bashsiz <morteza.bashsiz@gmail.com> wrote:
Hi everybody I have an asterisk(172.16.1.33) and freeswitch(172.16.1.30) My scenario :
1. Calls come to freeswitch ivr menu 2. In ivr calls transfer to asterisk after running an python script freeswitch start recording voice 3. In asterisk calls push to an queue
my python script is :
############################################################ import paramiko
hostname = '172.16.1.33' port = 3022 username = 'root' pkey_file = '/root/.ssh/id_rsa'
def get_agent_id(num): command="asterisk -rx \"pjsip show channels\" | grep -a1 \"CLCID: \\\"%s\\\"\" | grep Channel | cut -d \/ -f2 | cut -d\- -f1 " % (num) key = paramiko.RSAKey.from_private_key_file(pkey_file) s = paramiko.SSHClient() s.load_system_host_keys() s.connect(hostname, port, pkey=key) stdin, stdout, stderr = s.exec_command(command) result=str(stdout.read()) s.close() return result
#if __name__ == "__main__": # agent_id=get_agent_id('1000') # print (agent_id) import freeswitch as freeswitch def handler(session, args): caller_num = session.getVariable("caller") agent_num = get_agent_id(caller_num) session.setVariable("AGENT_NUM", agent_num); session.setVariable("CALLER_NUM", caller_num); ############################################################
my dial plan is :
############################################################
<extension name="test_dialplan"> <condition field="destination_number" expression="^2605$"> <action application="playback" data="phrase:shatel_before_queue"/> <action application="set" data="RECORD_TITLE=Recording ${destination_number} ${caller_id_number} ${strftime(%Y-%m-%d %H:%M)}"/> <action application="set" data="RECORD_DATE=${strftime(%Y-%m-%d %H:%M)}"/> <action application="set" data="RECORD_STEREO=true"/> <action application="set" data="caller=${caller_id_number}"/> <action application="python" data="test"/> <action application="record_session" data="$${base_dir}/recordings/ archive/${strftime(%Y-%m-%d-%H-%M-%S)}_${destination_ number}_${caller_id_number}_${AGENT_NUM}.wav"/> <action application="bridge" data="sofia/internal/261910@$$ {asterisk_vip}"/> </condition> </extension>
############################################################
*MY PROBLEM IS:*
when i want to use my variable AGENT_NUM it is null BUT when i use the python manually it returns true value
please help me what is my mistake ??????
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org