<div dir="ltr">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.</div><div class="gmail_extra"><br><div class="gmail_quote">On 25 March 2018 at 12:39, Morteza Bashsiz <span dir="ltr"><<a href="mailto:morteza.bashsiz@gmail.com" target="_blank">morteza.bashsiz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi everybody<div>I have an asterisk(172.16.1.33) and freeswitch(172.16.1.30) </div><div>My scenario :</div><div><ol><li>Calls come to freeswitch ivr menu<br></li><li>In ivr calls transfer to asterisk after running an python script freeswitch start recording voice</li><li>In asterisk calls push to an queue</li></ol><div>my python script is :</div></div><div><br></div><div>##############################<wbr>##############################</div><div><div>import paramiko</div><div><br></div><div>hostname = '172.16.1.33'</div><div>port = 3022</div><div>username = 'root'</div><div>pkey_file = '/root/.ssh/id_rsa'</div><div><br></div><div>def get_agent_id(num):</div><div> command="asterisk -rx \"pjsip show channels\" | grep -a1 \"CLCID: \\\"%s\\\"\" | grep Channel | cut -d \/ -f2 | cut -d\- -f1 " % (num)</div><div> key = paramiko.RSAKey.from_private_<wbr>key_file(pkey_file)</div><div> s = paramiko.SSHClient()</div><div> s.load_system_host_keys()</div><div> s.connect(hostname, port, pkey=key)</div><div> stdin, stdout, stderr = s.exec_command(command)</div><div> result=str(stdout.read())</div><div> s.close()</div><div> return result</div><div><br></div><div>#if __name__ == "__main__":</div><div># agent_id=get_agent_id('1000')</div><div># print (agent_id)</div><div>import freeswitch as freeswitch</div><div>def handler(session, args):</div><div> caller_num = session.getVariable("caller")</div><div> agent_num = get_agent_id(caller_num)</div><div> session.setVariable("AGENT_<wbr>NUM", agent_num);</div><div> session.setVariable("CALLER_<wbr>NUM", caller_num);</div></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">##############################<wbr>##############################</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br class="m_-4832695696919448260gmail-Apple-interchange-newline"></div><br></div><div>my dial plan is :</div><div><br></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">##############################<wbr>##############################</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br class="m_-4832695696919448260gmail-Apple-interchange-newline"></div> <extension name="test_dialplan"></div><div> <condition field="destination_number" expression="^2605$"></div><div> <action application="playback" data="phrase:shatel_before_<wbr>queue"/></div><div> <action application="set" data="RECORD_TITLE=Recording ${destination_number} ${caller_id_number} ${strftime(%Y-%m-%d %H:%M)}"/></div><div> <action application="set" data="RECORD_DATE=${strftime(%<wbr>Y-%m-%d %H:%M)}"/></div><div> <action application="set" data="RECORD_STEREO=true"/></div><div> <action application="set" data="caller=${caller_id_<wbr>number}"/></div><div> <action application="python" data="test"/></div><div> <action application="record_session" data="$${base_dir}/recordings/<wbr>archive/${strftime(%Y-%m-%d-%<wbr>H-%M-%S)}_${destination_<wbr>number}_${caller_id_number}_${<wbr>AGENT_NUM}.wav"/></div><div> <action application="bridge" data="sofia/internal/261910@$$<wbr>{asterisk_vip}"/></div><div> </condition></div><div> </extension></div><div><br></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">##############################<wbr>##############################</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br class="m_-4832695696919448260gmail-Apple-interchange-newline"></div><br></div><div><b>MY PROBLEM IS:</b></div><div><br></div><div>when i want to use my variable AGENT_NUM it is null</div><div>BUT</div><div>when i use the python manually it returns true value </div><div><br></div><div>please help me what is my mistake ??????</div></div>
<br>______________________________<wbr>______________________________<wbr>_____________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.<wbr>freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.<wbr>org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.<wbr>freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/<wbr>mailman/listinfo/freeswitch-<wbr>users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.<wbr>freeswitch.org/mailman/<wbr>options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>