There are no problems with the following. However, if you were to
comment out my %input = $AGI->ReadParse(); you will get:

t.pl: VAR1 =
t.pl: VAR2 = variable1
t.pl: VAR3 = variable2
t.pl: VAR4 = variable3

This happens because we got sent all the variables when an AGI is
executed regardless of
wether we want to read them or not.

When sub _readresponse in AGI.pm reads the buffer for the first time
those variables are still in there and get parsed. This causes 
get_variable to behave this way if no ReadParse(); has been issued.


/Mikael Ljunglöf


James Golovich wrote:
> I tried to duplicate this and wasn't able to, unless there is something
> I am missing here.  Can you try this same setup to see how it behaves?
>
> extensions.conf:
> exten => *43,1,Answer
> exten => *43,n,Playback(beep)
> exten => *43,n,Set(VAR1=variable1)
> exten => *43,n,Set(VAR2=variable2)
> exten => *43,n,Set(VAR3=variable3)
> exten => *43,n,Set(VAR4=variable4)
> exten => *43,n,AGI(/tmp/t.pl)
> exten => *43,n,Playback(beep)
>
>
> script:
> #!/usr/bin/perl
>
> use Asterisk::AGI;
>
> $AGI = new Asterisk::AGI;
>
> my %input = $AGI->ReadParse();
>
> my $var1 = $AGI->get_variable("VAR1");
> my $var2 = $AGI->get_variable("VAR2");
> my $var3 = $AGI->get_variable("VAR3");
> my $var4 = $AGI->get_variable("VAR4");
>
> $AGI->verbose("VAR1 = $var1");
> $AGI->verbose("VAR2 = $var2");
> $AGI->verbose("VAR3 = $var3");
> $AGI->verbose("VAR4 = $var4");
>
>
> output:
>     -- Starting simple switch on 'Zap/18-1'
>     -- Executing [...@internal:1] Answer("Zap/18-1", "") in new stack
>     -- Executing [...@internal:2] Playback("Zap/18-1", "beep") in new stack
>     -- <Zap/18-1> Playing 'beep.gsm' (language 'en')
>     -- Executing [...@internal:3] Set("Zap/18-1", "VAR1=variable1") in
> new stack
>     -- Executing [...@internal:4] Set("Zap/18-1", "VAR2=variable2") in
> new stack
>     -- Executing [...@internal:5] Set("Zap/18-1", "VAR3=variable3") in
> new stack
>     -- Executing [...@internal:6] Set("Zap/18-1", "VAR4=variable4") in
> new stack
>     -- Executing [...@internal:7] AGI("Zap/18-1", "/tmp/t.pl") in new stack
>     -- Launched AGI Script /tmp/t.pl
> /tmp/t.pl: VAR1 = variable1
> /tmp/t.pl: VAR2 = variable2
> /tmp/t.pl: VAR3 = variable3
> /tmp/t.pl: VAR4 = variable4
>     -- <Zap/18-1>AGI Script /tmp/t.pl completed, returning 0
>     -- Executing [...@internal:8] Playback("Zap/18-1", "beep") in new stack
>     -- <Zap/18-1> Playing 'beep.gsm' (language 'en')
>     -- Auto fallthrough, channel 'Zap/18-1' status is 'UNKNOWN'
>     -- Hungup 'Zap/18-1'
>     -- Starting simple switch on 'Zap/18-1'
>     -- Hungup 'Zap/18-1'
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to