Goto from AGI

I’m trying to call external context from my AGI:

$extension=$AGI->get_data(’/var/lib/asterisk/sounds/pin2/prosze_wybrac_numer’, 8000, 15);
$AGI->exec(‘ResetCDR’, ‘w’);
$AGI->exec(‘Goto’,‘pinset,’.$extension.’,1’);

on pinset there is extension with another script, that dial number from extension.

It work’s fine, but when I put it into loop:

for $i ( 0 … 3 ){
$extension=$AGI->get_data(’/var/lib/asterisk/sounds/pin2/prosze_wybrac_numer’, 8000, 15);
$AGI->exec(‘ResetCDR’, ‘w’);
$AGI->exec(‘Goto’,‘pinset,’.$extension.’,1’);
}

it doesnt run pinset. Do you know why?

Another problem is that I cant get variables HANGUPCAUSE and DIALSTATUS - its always empty when it’s run after goto.

what application do you run on dialplan when you go to pinset context ?

It’s another AGI script.

try Dialing local channels to jump to the extension .

$AGI->exec(“Dial”,“Local/1@pinset”)