[SR-Users] Evaluate Perl Return Value in Routing Logic

Henning Westerholt henning.westerholt at 1und1.de
Tue Aug 17 14:02:55 CEST 2010

On Tuesday 17 August 2010, Nicolas Rüger wrote:
> is there any way to use or evaluate the return-statements of a perl-script
>  in kamailio.cfg?
> I tried the following in the Routing Logic in kamailio.cfg:
> if (is_method("INVITE")) {
> 	if (perl_exec("my_perl_subroutine") == -1){
> 	 	xlog("PERL returns -1 \n");
> 	}
> }
> Doesn't work.
> The bad thing is that the return-values of the - perl_exec("XXX") - call
>  are not the same that the perl subroutine "XXX" returns.
> That's at least what I strongly believe after testing.
> I do need to read/evaluate the return-value of the perl-subroutine in the
>  Routing Logic to define different routes depending on what the
>  perl-subroutine returns.
> Is there any way to do that???

Hi Nicolas,

i just checked in the code of perl/perlfunc.c:perl_exec2(..) in the module, it 
seems that it according to the code it should return the result from the perl 
method, or -1 on internal error or wrong parameter before execution.

If this not work, then its probably a bug in the module. Maybe you can add 
some debugging information into this code statement to help with your tests. 

Another idea, if you don't like to digg in the code, for returning some data 
from perl to the script would be to use OpenSER::AVP and fill the return value 
(maybe with some wrapper) in an AVP which you then read out later.



More information about the sr-users mailing list