[asterisk-users] carefulwrite: write() returned error:Brokenpipe

Danny Nicholas danny at debsinc.com
Thu Oct 22 13:14:47 CDT 2009


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: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] 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:asterisk-users-bounces at lists.digium.com] 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       sedwards at sedwards.com      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




More information about the asterisk-users mailing list