[OpenSER-Users] Global variables in scripts.

Robert Dyck rob.dyck at telus.net
Fri Apr 25 18:49:00 CEST 2008


I vote for a global variable that is visible any where in the script and that 
can be initialized at startup without using a preprocessor.

On Friday 25 April 2008, Daniel-Constantin Mierla wrote:
> Hello,
>
> it is not possible to initialize the script variables at startup.
>
> If all you need is static values, then you can use M4 defines and
> pre-process the script. Check:
>
> http://www.openser.org/docs/scripting.html
>
> Might be a good addition to enhance with script variable initialization
> at startup, maybe in the same fashion as with shared variables
> ($shv(..)) in cfgutils module.
>
> Cheers,
> Daniel
>
> On 04/25/08 17:23, Peter Lemenkov wrote:
> > Hello All!
> >
> > Are any ways to define global variables in openser's scripts?
> >
> > I need somethng like
> >
> > ==========================================
> >
> > $var(router1) = "192.168.1.1"
> > $var(router2) = "192.168.1.2"
> >
> > route {
> >  ...
> >  myfunc1("$ru")
> > switch($retcode)
> >  case 1:
> >   $ruri = "sip:" + $rU + "@" + $var(route1);
> >  case 2:
> >   $ruri = "sip:" + $rU + "@" + $var(route2);
> > }
> >
> > failure_route[1] {
> >  myfunc2("$ru")
> > switch($retcode)
> >  case 1:
> >   $ruri = "sip:" + $rU + "@" + $var(route1);
> >  case 2:
> >   $ruri = "sip:" + $rU + "@" + $var(route2);
> > }
> >
> > onreply_route[1] {
> >  myfunc3("$ru")
> > switch($retcode)
> >  case 1:
> >   $ruri = "sip:" + $rU + "@" + $var(route1);
> >  case 2:
> >   $ruri = "sip:" + $rU + "@" + $var(route2);
> > }
> >
> > ==========================================
> >
> > Right now (AFAIK) variables may be defined only within one route.
> > Maybe I missing something? What's the scope of visibility of variables
> > within configuration script?






More information about the Users mailing list