[Asterisk-Dev] PHP AGI - seems to ignore anything but EXEC

Terence Parker terence at parker.com.hk
Sun May 9 20:26:03 MST 2004


Thanks for that, your function worked well.

Just out of interest, mine was:

function send($command, $parameter) {
                global $stdout;
                $command_full = $command ." " .str_replace(" ", "\ ",
$parameter) ."\n";
                fputs ($stdout, $command_full);
                fflush($stdout);
}

The reason for all the faffing about with str_replace was becuase I notice
festival only takes the first word of each sentence, so I escaped the
spaces. With yours of course I could simply use quotes and escape the
quotes, but I don't know why I chose to do the above. That said, I don't see
why it should have any problems with SAY DIGITS 2345 - since there is
nothing to escape in the 2345.

Anyways.... silly me. Thanks for the help.

- Terence



> Hi,
>
> Don't forget to add fflush($stdout) after issuing each command because PHP
uses
> buffering for its output.
>
> I've uses next function to interact with Asterisk from PHP script and it
works
> well:
> function ast_exec($command)
> {
>         global $stdin, $stdout;
>         fputs($stdout, "$command\n");
>         fflush($stdout);
>         $str = chop(fgets($stdin, 1024));
>         return($str);
> }
>
>
> WBR,
> Paul.





More information about the asterisk-dev mailing list