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?
Peter Lemenkov writes:
Are any ways to define global variables in openser's scripts?
I need somethng like
you should be able to achieve what you want in your example by storing the ip addresses in two AVPs in a route block. then they are usable in onreply and failure route blocks of the same transaction. if you use VARs, values are not usable in onreply and failure route.
-- juha
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?
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?
Robert Dyck schrieb:
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.
I fI got it right this already is available by using $shv(..) (and you even can modify it via MI commands)
regards klaus
On Monday 28 April 2008, Klaus Darilion wrote:
Robert Dyck schrieb:
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.
I fI got it right this already is available by using $shv(..) (and you even can modify it via MI commands)
Sorry, I cannot find it documented. What is the syntax? I tried it on 1.3.1.
I tried $shv(test)=123 and $shv(test)="123" and got "Apr 28 08:52:34 [14769] CRITICAL:core:yyerror: parse error in config file, line 20, column 7-17: syntax error Apr 28 08:52:34 [14769] CRITICAL:core:yyerror: parse error in config file, line 20, column 7-17: Apr 28 08:52:34 [14769] ERROR:core:main: bad config file (2 errors)"
This is part of the upcoming 1.4 release: http://www.openser.org/docs/modules/1.4.x/cfgutils.html#id2480638
Regards, Ovidiu Sas
On Mon, Apr 28, 2008 at 12:10 PM, Robert Dyck rob.dyck@telus.net wrote:
On Monday 28 April 2008, Klaus Darilion wrote:
Robert Dyck schrieb:
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.
I fI got it right this already is available by using $shv(..) (and you even can modify it via MI commands)
Sorry, I cannot find it documented. What is the syntax? I tried it on 1.3.1.
I tried $shv(test)=123 and $shv(test)="123" and got "Apr 28 08:52:34 [14769] CRITICAL:core:yyerror: parse error in config file, line 20, column 7-17: syntax error Apr 28 08:52:34 [14769] CRITICAL:core:yyerror: parse error in config file, line 20, column 7-17: Apr 28 08:52:34 [14769] ERROR:core:main: bad config file (2 errors)"
Users mailing list Users@lists.openser.org http://lists.openser.org/cgi-bin/mailman/listinfo/users