Hey Ron,<div>Thanks for taking out time for this weird issue. No this is the only code thats running and I simply copy pasted it here. I'll go through the artivle you mentioned and other advices you gave may hopefully resolve this issue. But in general its beyond my logic to see whats actually going on here. Simply mind blowing trick for me :)</div>
<div><br></div><div>Just to add here, even changing the arrangement of verbose statement above or below the Addheader statement changes the variables as well.</div><div><br></div><div>Additional Details:</div><div>I tested the code without enclosing it in a sub , in a very small agi just for this and this same code was giving me 100% results. So that means that the production AGI/perl code has something in it thats causing the issue !? </div>
<div><br>Regards,</div><div>Sammy</div><div><br><div class="gmail_quote">On Sat, Feb 11, 2012 at 11:20 PM, Ron Bergin <span dir="ltr"><<a href="mailto:rkb@i.frys.com">rkb@i.frys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">Sammy Govind wrote:<br>
> Hello all,<br>
><br>
> I'm struck with a very strange problem today. I've an AGI with some code<br>
> subroutine snippet as follows:<br>
><br>
><br>
> sub enable_sbc($) {<br>
> my $carrier = shift;<br>
> my $tmp = substr($carrier,1);<br>
> my $jkh = $tmp;<br>
> $server_port = $ast_agi->get_variable("SIPPEER($jkh,port)");<br>
> $ser_ip = $ast_agi->get_variable("SIPPEER($tmp,ip)");<br>
> $ast_agi->exec("SIPAddHeader","P-PORT: $server_port");<br>
> $ast_agi->exec("SIPAddHeader","P-IPADDRESS: $ser_ip");<br>
> return 0;<br>
> }<br>
><br>
><br>
> Where $carrier resolves to "@my-carrier"<br>
><br>
> Strangely and very weird get variable is returning correct values on<br>
> console as given below but the variables containing the values gets lost<br>
> or<br>
> confused with each other !<br>
><br>
> <SIP/sipproxy3.32-00000000>AGI Rx << GET VARIABLE SIPPEER(my-carrier,port)<br>
> <SIP/sipproxy3.32-00000000>AGI Tx >> 200 result=1 (5060)<br>
> <SIP/sipproxy3.32-00000000>AGI Rx << GET VARIABLE SIPPEER(my-carrier,ip)<br>
> <SIP/sipproxy3.32-00000000>AGI Tx >> 200 result=1 (192.168.2.19)<br>
> <SIP/sipproxy3.32-00000000>AGI Rx << EXEC SIPAddHeader "P-PORT: "<br>
> -- AGI Script Executing Application: (SIPAddHeader) Options: (P-PORT:<br>
> )<br>
> <SIP/sipproxy3.32-00000000>AGI Tx >> 200 result=0<br>
> <SIP/sipproxy3.32-00000000>AGI Rx << EXEC SIPAddHeader "P-IPADDRESS: 5060"<br>
> -- AGI Script Executing Application: (SIPAddHeader) Options:<br>
> (P-IPADDRESS: 5060)<br>
> <SIP/sipproxy3.32-00000000>AGI Tx >> 200 result=0<br>
><br>
><br>
> Anyone please help. Am I doing anything wrong ?<br>
><br>
><br>
> Regards,<br>
> Sammy.<br>
</div></div>> --<br>
> _____________________________________________________________________<br>
<br>
Did you copy/paste the code in the email posting, or did you retype it?<br>
<br>
Is it possible that you have multiple versions of the script and the wrong<br>
one is being executed?<br>
<br>
First step I'd suggest, after checking the above possibility, is to remove<br>
the prototype. It is almost never needed/wanted and can introduce bugs if<br>
not used correctly.<br>
<a href="http://www.modernperlbooks.com/mt/2009/08/the-problem-with-prototypes.html" target="_blank">http://www.modernperlbooks.com/mt/2009/08/the-problem-with-prototypes.html</a><br>
<br>
Next, are you using the strict and warnings pragmas? If not, you should<br>
add them and fix the problems that they point out.<br>
<br>
Next, declare $server_port and $ser_ip as lexical vars in the sub.<br>
<br>
Finally, add a couple debugging statements after the get_variable<br>
statements to verify/dump the vars.<br>
<br>
---<br>
Ron Bergin<br>
<br>
</blockquote></div><br></div>