[asterisk-users] Problem forwarding a call with an AGI script

Stefan Guenther asterisk01 at in-put.de
Wed Feb 6 06:50:33 CST 2008


Hi,

I'm trying to achieve the following:

Incoming call for user A (97), user A make a blind transfer to user B's 
phone (96).
User B's phone rings and since there is no one to take the call, it 
returns the call to User A with an AGI script.

The dialplan looks like this:

[local]
....

exten => 96,1,Dial(SIP/user4,10,tr)
exten => 96,2,AGI(transfer.php)

exten => 97,1,NoOp("MARKE1------------")
exten => 97,2,DIAL(SIP/user1,20,tr)
exten => 97,3,NoOp("MARKE2-------------")
exten => 97,4,BUSY()

transfer.php:

#! /usr/bin/php -q

<?php
$i=0;
ob_implicit_flush(true);
set_time_limit(6);
error_reporting(0);
$stdin=fopen("php://stdin","r");
while(!feof($stdin)){
         $temp = fgets($stdin);
         $temp = str_replace("\n","",$temp);
         $s = explode(":",$temp);
         if( $s[0]=="agi_dnid"){
// $s[1] contains the number that has forwarded the call
                 $stdout=fopen("php://stdout","w");
                 fwrite($stdout,"NOOP(dummy)");
                 fwrite($stdout,"SET CONTEXT local");
                 fwrite($stdout,"SET EXTENSION $s[1]");
                 fwrite($stdout,"SET PRIORITY 1");
                 fclose($stdout);
                 }
         }
fclose($stdin);
?>

And here is the output on the cli:

-- Launched AGI Script /var/lib/asterisk/agi-bin/transfer.php
AGI Tx >> agi_request: transfer.php
AGI Tx >> agi_channel: Local/96 at local-14a8,2
AGI Tx >> agi_language: en
AGI Tx >> agi_type: Local
AGI Tx >> agi_uniqueid: asterisk-1202301352.342
AGI Tx >> agi_callerid: 98
AGI Tx >> agi_calleridname: Stefan Guenther
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: unknown
AGI Tx >> agi_rdnis: 97
AGI Tx >> agi_context: local
AGI Tx >> agi_extension: 96
AGI Tx >> agi_priority: 2
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << LI>
AGI Tx >> 510 Invalid or unknown command
     -- Nobody picked up in 20000 ms
     -- Executing [97 at local:3] NoOp("SIP/sguenther-08251bf0", 
""MARKE2-------------"") in new stack
     -- Executing [97 at local:4] Answer("SIP/sguenther-08251bf0", "") in 
new stack
   == Auto fallthrough, channel 'SIP/sguenther-08251bf0' status is 
'NOANSWER'
     -- Executing [h at local:1] DeadAGI("SIP/sguenther-08251bf0", 
"hangup.php") in new stack

Why doesn't the script jump to priority 1 in extension 97?
Is there really an "Invalid or unknown command", I couldn't find one?

Thanks for your help,

Stefan
-- 

********************************************
in-put GbR - Das Linux-Systemhaus
Stefan-Michael Guenther
Geschaeftsfuehrer
Moltkestrasse 49     D-76133 Karlsruhe
Tel./Fax : +49 (0)721 / 83044 - 98/93
http://www.in-put.de
********************************************
      Schulungen  Installationen
          Beratung   Support
       Voice-over-IP-Loesungen
********************************************




More information about the asterisk-users mailing list