[SR-Users] Fwd: Re: reading php script result with exec_avp

Gertjan Wolzak g.wolzak at kazlow.nl
Thu Jun 6 13:48:38 CEST 2019


Hello Kamailions,

After the feedback from Daniel, I have tried some other things.

The php script works, for testing purposes I changed the php action to 
write a text file in the /tmp directory.

This works when the incoming call is handled by Kamailio, so I know the 
script gets executed.

But when the script echo's the needed value the kamailio line below does 
not receive the value in the avp variable:

     exec_avp("/usr/bin/php /var/lib/kamailio/scripts/test.php 
$var(timeControlId)", "$avp(s:numberid)");

I also have tried it with $avp(i:1), but both options do not work.

I am stil thinking that my php script is not presenting the value in the 
correct manner...

Should a value presented by an echo command be read by the exec_avp command?

Rgds,

Gertjan Wolzak



-------- Forwarded Message --------
Subject: 	Re: [SR-Users] reading php script result with exec_avp
Date: 	Thu, 6 Jun 2019 09:16:12 +0200
From: 	Gertjan Wolzak <g.wolzak at kazlow.nl>
To: 	Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>



Goodmorning All,

Daniel, thank you for your feedback.

The relative path was just for example, in the Kamailio config I am 
useing the absolute path.

But the feedback does help me point my nose in the right direction.

Rgds,

Gertjan


On 6/5/19 2:48 PM, Daniel-Constantin Mierla wrote:
> Hello,
>
> are you sure that the script is executed? You give a relative path and
> kamailio changes working directory to / if you don't give -w parameter?
> Try with absolute path.
>
> Cheers,
> Daniel
>
> On 05.06.19 14:10, Gertjan Wolzak wrote:
>> Hello Kamailions,
>>
>> I have the following challenge.
>>
>> I want to create a time dependent callerid, based on the time of a
>> outgoing call a callerid will be set.
>>
>> I have a php script, that provides me an id number which relates to an
>> cli.
>>
>> When I run that php script from the console, the id is shown in the
>> console.
>>
>> When I run the script within the kamailio configuration,
>> exec_avp("../script.php", "$avp(s:cliId)"); ,no output commande is
>> saved in the avp variable.
>>
>> I think I am not presenting the result of the php script correctly. I
>> have tried with an echo $variable; and with and fwrite(STDOUT,
>> $variable); but no luck.
>>
>> I'm not a PHP coder so I am not surprised of the missing luck, but
>> maybe somebody has a golden tip for me?
>>
>> Rgds,
>>
>> Gertjan
>>
>>
>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190606/eb8463a0/attachment.html>


More information about the sr-users mailing list