[Asterisk-Users] First AGI help..

WipeOut wipe_out at onetel.com
Wed Nov 5 04:38:25 MST 2003


I am trying to write my first AGI script..

I cant seem to get it to work.. I am trying PHP in preference (I know 
this is frowned upon) but I can't get it to work with perl either.. I 
guess I just don't understand it correctly..

All I am trying to do is get the script to make a call using "Dial" so 
that I can get an idea of how it works.. My experience is really only in 
PHP based websites so this is a whole new ball game for me..

Thanks for any help.. and any samples (even offlist) would be greatly 
appreciated..

I have setup in extensions.conf like this for testing..

exten => 7000,1,agi(test1.php)
exten => 7001,1,agi(test2.pl)

test1.php script..

<?php
// From Kapjod's sample..
ob_implicit_flush(true);
set_time_limit(0);
$err = fopen("php://stderr","w");
$in = fopen("php://stdin","r");
$out = fopen("php://stdout","w");

//This works..
fputs($out, "Verbose \"Calling phone"\n");
// This doesn't
fputs($out, "exec(Dial(sip/2012)\n");

fclose($in);
fclose($out);
fclose($err);
?>


test2.pl script..

#!/usr/bin/perl
# taken from a sample file..
$|=1;
while(<STDIN>) {
        chomp;
        last unless length($_);
        if (/^agi_(\w+)\:\s+(.*)$/) {
                $AGI{$1} = $2;
        }
}

#This works..
print STDOUT "AGI Environment Dump:\n";
foreach $i (sort keys %AGI) {
        print STDOUT "Verbose \"-- $i = $AGI{$i}\"\n";
}

# This does not start a call..
print STDOUT "exec(Dial(sip/2012)\n)"






More information about the asterisk-users mailing list