Perl AGI: Read Variable With Quotes

Home » Uncategorized » Perl AGI: Read Variable With Quotes
Uncategorized 4 Comments

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:

I get “” in the variable $pai.

P-Asserted-Identity: “John Doe”

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

4 thoughts on - Perl AGI: Read Variable With Quotes

  • 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@sedwards.com Voice: +1-760-468-3867 PST
    https://www.linkedin.com/in/steve-edwards-4244281

  • In article <20200124154749.46da5eb6@go.imp.ch>, Benoit Panizzon wrote:

    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”

    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@softins.co.ukhttp://www.softins.co.uk Play: tony@mountifield.orghttp://tony.mountifield.org

  • 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