Benoit Panizzon
2020-Jan-24 14:47 UTC
[asterisk-users] Perl AGI: read variable with quotes
Hi Gang I have stumbled of this problem. I need the P-Asserted-Identity header in an AGI scrip. In the Dial-Plan I do: same => n,Set(PAI=${PJSIP_HEADER(read,P-Asserted-Identity)}) In the AGI I do: my $pai = $AGI->get_variable(PAI); This works fine, unless the PAI contains quotes: P-Asserted-Identity: <sip:1000 at 1.2.3.4:5060;user=phone> I get "<sip:1000 at 1.2.3.4:5060;user=phone>" in the variable $pai. P-Asserted-Identity: "John Doe" <sip:2000 at 1.2.3.4:5060;user=phone> Is getting me $pai containing just "John". Anyone a clue how I could get the whole header? Mit freundlichen Grüssen -Benoît Panizzon- -- I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________ Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________
On Fri, 24 Jan 2020, Benoit Panizzon wrote:> I have stumbled of this problem. > > I need the P-Asserted-Identity header in an AGI scrip. > > In the Dial-Plan I do: > > same => n,Set(PAI=${PJSIP_HEADER(read,P-Asserted-Identity)}) > > In the AGI I do: > > my $pai = $AGI->get_variable(PAI); > > This works fine, unless the PAI contains quotes: > > P-Asserted-Identity: <sip:1000 at 1.2.3.4:5060;user=phone> > > I get "<sip:1000 at 1.2.3.4:5060;user=phone>" in the variable $pai. > > P-Asserted-Identity: "John Doe" <sip:2000 at 1.2.3.4:5060;user=phone> > > Is getting me $pai containing just "John". > > Anyone a clue how I could get the whole header?1) Does the PAI channel variable contain the full header? Try 'verbose(PAI = ${PAI})' or something similar. 2) How about doing 'GET FULL VARIABLE' in your Perl script? You can set the channel variable PAI in the AGI if needed back in the dialplan. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST https://www.linkedin.com/in/steve-edwards-4244281
Tony Mountifield
2020-Jan-24 16:38 UTC
[asterisk-users] Perl AGI: read variable with quotes
In article <20200124154749.46da5eb6 at go.imp.ch>, Benoit Panizzon <benoit.panizzon at imp.ch> wrote:> Hi Gang > > I have stumbled of this problem. > > I need the P-Asserted-Identity header in an AGI scrip. > > In the Dial-Plan I do: > > same => n,Set(PAI=${PJSIP_HEADER(read,P-Asserted-Identity)}) > > In the AGI I do: > > my $pai = $AGI->get_variable(PAI); > > This works fine, unless the PAI contains quotes: > > P-Asserted-Identity: <sip:1000 at 1.2.3.4:5060;user=phone> > > I get "<sip:1000 at 1.2.3.4:5060;user=phone>" in the variable $pai. > > P-Asserted-Identity: "John Doe" <sip:2000 at 1.2.3.4:5060;user=phone> > > Is getting me $pai containing just "John". > > Anyone a clue how I could get the whole header?First you need to identify whether the problem is in the Set() or in the $AGI->get_variable(PAI) (shouldn't that be ("PAI")?) Add a line to your dialplan just after the line you quoted: same => n,NoOp(PAI=${PAI}) Then turn on verbose logging and try the call. Look at the logged NoOp line and see if it contains just the 'John' or the whole value '"John Doe" <sip:2000 at 1.2.3.4:5060;user=phone>' If it contains the whole value, then the problem is in the AGI library reading the variable. If it just contains John, the problem is in the Set() operation in the dialplan. Cheers Tony -- Tony Mountifield Work: tony at softins.co.uk - http://www.softins.co.uk Play: tony at mountifield.org - http://tony.mountifield.org
On Fri, 24 Jan 2020, Steve Edwards wrote:> 2) How about doing 'GET FULL VARIABLE' in your Perl script?Sorry. After a couple more cups of tea I think this was a bit vague. Try whatever call/method in your library that does 'GET FULL VARIABLE' on '${PJSIP_HEADER(read,P-Asserted-Identity)}' in your AGI. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST https://www.linkedin.com/in/steve-edwards-4244281
Benoit Panizzon
2020-Jan-27 08:59 UTC
[asterisk-users] Perl AGI: read variable with quotes
Hi Gang Thank you for the replies. I sorted this out. I got tricked by $AGI->verbose(Pai: $pai) which cripples the output. The variable passed on is complete. My regex to extract the phone number from that variable was broken when there was a quoted string before the URI. Mit freundlichen Grüssen -Benoît Panizzon- -- I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________ Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________
Reasonably Related Threads
- Perl AGI: read variable with quotes
- pre-dial handler, how to access variables from calling channel?
- With ARI, is it possible to create (originate) a call and pass both the caller id name and number?
- PJSIP and P-Asserted-Identity
- Two problems with the Perl AGI