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

Gertjan Wolzak g.wolzak at kazlow.nl
Fri Jun 7 09:44:52 CEST 2019


Thanks again Daniel,

Ive run the scenario with debug enabled:

{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: *** 
cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1688 a=63 n=assign
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: *** 
cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1689 a=25 n=sql_result_free
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: *** 
cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1690 a=26 n=xlog
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) INFO: <script>: 
timecontrolID is 3{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: 
*** cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1708 a=16 n=if
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: *** 
cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1695 a=26 n=xlog
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) INFO: <script>: Start 
time_cli.php{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: *** 
cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1696 a=26 n=exec_avp
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: <core> 
[core/md5utils.c:67]: MD5StringArray(): MD5 calculated: 
8c2e9a582ac4c995578e3d044bfcb29f
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_CONTENT_LENGTH=306
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_SUPPORTED=replaces
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): 
SIP_HF_ALLOW_EVENTS=talk,hold,conference,refer,check-sync
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_USER_AGENT=Yealink SIP-T19P_E2 
53.81.188.7 0015659a9931
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_MAX_FORWARDS=69
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_ALLOW=INVITE, INFO, PRACK, ACK, 
BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, 
UPDATE, MESSAGE
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_CONTENT_TYPE=application/sdp
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_PROXY_AUTHORIZATION=Digest 
username="0015659a9931", realm="10.88.77.172", 
nonce="XPoVyVz6FJ0/jlPlCWRW53kunxvJVCRE", 
uri="sip:0105623656 at 10.88.77.172:5060", 
response="af5ba0e31bc2ad9e4e04e62d4a51d79b", algorithm=MD5
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): 
SIP_HF_CONTACT=<sip:0015659a9931 at 10.88.77.184:5060>
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_CSEQ=2 INVITE
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_CALLID=0_3892118735 at 10.88.77.184
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): 
SIP_HF_TO=<sip:0105623656 at 10.88.77.172:5060>
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_FROM="0015659a9931" 
<sip:0015659a9931 at 10.88.77.172:5060>;tag=1505301176
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_hf.c:293]: print_hf_var(): SIP_HF_VIA=SIP/2.0/UDP 
10.88.77.184:5060;branch=z9hG4bK3089829295
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: exec 
[exec_mod.c:215]: w_exec_avp_helper(): executing [/usr/bin/php 
/var/lib/kamailio/scripts/test.php 3]
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: <core> 
[main.c:867]: sig_usr(): SIGCHLD received: we do not worry about 
grand-children
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: *** 
cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1697 a=26 n=xlog
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) INFO: <script>: CLI 
number id is <null>{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: 
*** cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1705 a=16 n=if
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) exec: *** 
cfgtrace:request_route=[FROMUPDATE_EXTERN] 
c=[/etc/kamailio/kamailio.cfg] l=1708 a=26 n=uac_replace_from
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: uac [uac.c:422]: 
ki_replace_from(): dsp=0x7ffe4637b080 (len=11) , uri=0x7ffe4637b090 (len=33)
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: uac 
[replace.c:319]: replace_uri(): removing display ["0015659a9931"]
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: uac 
[replace.c:331]: replace_uri(): adding new display [+3156666000]
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: uac 
[replace.c:361]: replace_uri(): uri to replace 
[sip:0015659a9931 at 10.88.77.172:5060]
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: uac 
[replace.c:362]: replace_uri(): replacement uri is 
[sip:+3156666000 at 10.88.77.172:5060]
{1 2 INVITE 0_3892118735 at 10.88.77.184} 6(71459) DEBUG: uac 
[replace.c:506]: replace_uri(): encode 
is=<AAAAABsDAAAAAw9XCQkDcXEBHhYAFhkAGR8GBQgPBQYGMA--> len=48

You can see that after the script is run there is a message about 
grand-children, then the info about the CLI number id being empty...

So I still feel if I am not presenting the value correct..

The php script just echo's  a value:  echo $TIME_CLI;

Rgds,

Gertjan




On 6/6/19 2:29 PM, Daniel-Constantin Mierla wrote:
>
> Hello,
>
> run with debug=3 in kamailio.cfg and see if you spot any debug message 
> that can help figuring out what happens.
>
> Cheers,
> Daniel
>
> On 06.06.19 13:48, Gertjan Wolzak wrote:
>>
>> 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
>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
> -- 
> Daniel-Constantin Mierla --www.asipto.com
> www.twitter.com/miconda  --www.linkedin.com/in/miconda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190607/5e89105f/attachment.html>


More information about the sr-users mailing list