[asterisk-users] broken pipe in perl agi
Elliot Otchet
elliot.otchet at callingcircles.com
Fri Jun 5 08:59:25 CDT 2009
FYI - It works fine under perl 5.8.8 on RHEL5.2 w/ Asterisk 1.4.24.1
You might want to check your perl modules to see if they're up to date.
Regards,
Elliot
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Danny Nicholas
Sent: Friday, June 05, 2009 9:43 AM
To: 'Asterisk Users Mailing List - Non-Commercial Discussion'
Subject: Re: [asterisk-users] broken pipe in perl agi
You're on the right track, Steve but that didn't do it either. Here is the
Perl snippet:
use strict;
use warnings;
my $towatch = $ARGV[0];
my $a=0;
my $retval=undef;
# show hints will get hint information from the dialplan
while ($a<1) {
my $cmda = '/usr/sbin/asterisk -rx "core show hints"|';
#### Get Trunk Information ####
my %lines;
my $lineseq=0;
$SIG{'PIPE'} = 'IGNORE';
open (my $trunk_info,$cmda) or print STDOUT "Broken pipe\n";
if ($trunk_info) {
while (<$trunk_info>) {
if ($_ =~ /internal/) {
if ($_ =~ /$towatch/) {
$lines{$lineseq} = $_;
$lineseq++;
}
}
}
close $trunk_info;
}
sleep 2;
for (my $i=0;$i<=$lineseq;$i++) {
if ($lines{$i}) {
my $c = unpack("x74 a16", $lines{$i});
$c =~ s/\s//gx;
$retval=1;
print STDOUT "SET VARIABLE LINESTAT \"$c\" \r\n";
<STDIN>;
}
}
$a++;
}
# if /var/run/asterisk.ctl is not mod 777, no result so we return a dummy
Idle
if (! $retval) {
my $c = "Idle";
print STDOUT "SET VARIABLE LINESTAT \"$c\" \r\n";
<STDIN>;
}
exit;
If there is an active call on the extension, it works. If not, the "broken
pipe" message is returned.
-----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, June 04, 2009 6:37 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] broken pipe in perl agi
On Thu, 4 Jun 2009, Danny Nicholas wrote:
> Here's what I got from agi debug:
> agi debug
> AGI Debugging Enabled
> *CLI> AGI Tx >> agi_request: hintcheck.agi
[snip]
> AGI Rx << SET VARIABLE LINESTAT="Idle"
> AGI Tx >> 200 result=1
> [Jun 4 13:33:42] ERROR[28261]: utils.c:979 ast_carefulwrite: write()
> returned error: Broken pipe
I'm guessing you're not reading the last "200 result=1" before exiting or
closing the pipe.
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
_______________________________________________
-- 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
This message is intended only for the use of the individual (s) or entity to which it is addressed and may contain information that is privileged, confidential, and/or proprietary to Calling Circles LLC and its affiliates. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, forwarding or copying of this communication is prohibited without the express permission of the sender. If you have received this communication in error, please notify the sender immediately and delete the original message.
More information about the asterisk-users
mailing list