Strictly a shot in the dark, but have you tried
$loc=$agi.get_variable('CHANNEL') ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100729/6bfdb5c2/attachment.htm