So this would actually be proper?
Here is the "failing" code
> #!/usr/local/bin/perl
> use strict;
> use warnings;
>
> sub setvar {
> my ($var, $val) = @_;
> print STDOUT "SET VARIABLE $var \"$val\" \r\n";
> while(<STDIN>) {
> m/200 result=0/ && last;
> }
> return;
> }
>
> # turn off I/O buffering
> $| = 1;
>
> # get trunk information
> $SIG{'PIPE'} = 'IGNORE';
> my $images='TRUE';
> my $checks='TRUE';
> my $envvars = <STDIN>;
> &setvar("TEST_RETURN", "OK");
> &setvar("CHECKS", $checks);
> &setvar("IMAGES", $images);
> exit;
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Steve Edwards
Sent: Thursday, October 22, 2009 1:07 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] carefulwrite: write() returned
error:Brokenpipe
Un-top-posting...
> [mailto:[email protected]] On Behalf Of Tilghman
> Lesher
> What is clearly wrong with your script is that you're failing to
> retrieve all of the setup information that is sent when the script first
> starts up. Each "response" that you're getting is actually setup
> information, and you exit early, which is why the final response is not
> able to be sent.
On Thu, 22 Oct 2009, Danny Nicholas wrote:
> If it was clear, I wouldn't be writing; You are suggesting something like
> this?
>> sub setvar {
>> my ($var, $val) = @_;
>> print STDOUT "SET VARIABLE $var \"$val\" \r\n";
>> my $rv=<STDIN>;
>> while(<STDIN>) {
>> m/200 result=0/ && last;
>> }
>> return;
>> }
Your previous script violates the AGI protocol because it does not read
the AGI environment before issuing an AGI request.
So, when you issue a request and read a response, you are reading a piece
of the AGI environment, not the response to your request.
Then, when you exit, you haven't read all of the AGI environment or the
responses to your requests so, you get a "reprimand."
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards [email protected] Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users