[Freeswitch-users] Mod perl using $session->setVariable inline

Michael Jerris mike at jerris.com
Wed Dec 10 21:01:55 MSK 2014


That perl script will not run at all until the dialplan parsing is complete.  You would need to run the perl script inline (which I am not sure we allow) or run the perl script, then transfer to re-enter the dialplan after it is run.

> On Dec 10, 2014, at 12:56 PM, Liam Farr <liam at maxumdata.com> wrote:
> 
> Heres an expanded example;
> 
> 
> 
> 
> 
> Extension runs the perl script as part of the public dialplan first;
> 
> 
> 
> <extension name="run-script" continue="true">
> 
>    <condition>
> 
> 	  <action application="perl" data="/etc/freeswitch/scripts/my-script.pl <http://my-script.pl/>"/>
> 
>    </condition>
> 
> </extension>
> 
> 
> 
> 
> 
> Script sets some variables;
> 
> 
> 
> $my_value = "123";
> 
> $session->setVariable('some_var',$my_value);
> 
> 
> 
> 
> 
> Use that variable later in another extension in the public dialplan as a condition selector;
> 
> 
> 
> 
> 
> <extension name="bridge-call" >
> 
>    <condition field="context" expression="public" />
> 
>    <condition field="${some_var}" expression="123" >
> 
> 	   <action application="set" data="call_direction=inbound"/>
> 
> 	   <action application="bridge" data="sofia/internal/${destination_number}@1.2.3.4:5060 <http://destination_number}@1.2.3.4:5060>" />
> 
>    </condition>
> 
> </extension>
> 
> 
> 
> 
> 
> However this will fail, because the perl script "$session->setVariable" run earlier is not inline, so you cant make use of it in the condition (<condition field="${some_var}" expression="123" >) in the second extension that exists in a later part of the public dialplan. Hence I need a way to set inline variables from my perl script.
> 
> 
> 
> 
> 
> Cheers
> 
> 
> 
> Liam Farr
> 
> 
> 
> 
> On 11 December 2014 at 06:28, Michael Jerris <mike at jerris.com <mailto:mike at jerris.com>> wrote:
> If you are in a perl script using session->setVariable, how are you still in the dialplan?  This doesn't make sense to me.  There should be no need for an inline if you are already in the script.
> 
> > On Dec 10, 2014, at 4:20 AM, Liam Farr <liam at maxumdata.com <mailto:liam at maxumdata.com>> wrote:
> >
> > Hi,
> >
> > I need to set a variable using a perl script inline.
> >
> > Normally I would use $session->setVariable('some_var',$my_value);
> >
> > However I cant find any options to execute this inline / as an inline action. (I need to evaluate the variable later in the hunting phase of the dialplan hence need it to be an inline action).
> >
> > Is there a way to do this?
> >
> > Or is there another way to achieve the same result, e.g. hacking $session->execute("set","some_var=$my_value") to run as an inline action?
> >
> > Any help would be much appreciated, I've scoured the wiki, confluence and git repo and come up empty.
> >
> > --
> > Kind Regards
> >
> >
> > Liam Farr
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20141210/168eba1f/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list