Dear monks. I have been helped by you before but is stuck again.

Components: [asterisk server] [fastagi server] [perlscript running on fastagi server] [bash script running a gawk-script]

Dataflow: [asterisk server] reads and writes data on stdin and stdout via [fastagi server] back and forth to the [perlscript]. This connection works ok.

When [asterisk server] communicates directly with the [bash script running a gawk-script] via the built-in asterisk agi-facility, the [bash script running a gawk-script] works ok. THE [..gawk-script] USES fflush() when it writes to stdout.

Problem: What I want is the [perlscript..] to call [..gawk-script] and data on stdin and stdout in the [..gawk-script] to pass through [perlscript...] and [fastagi server] to reach/be sent from [asterisk..].

From debuglines sent to files inside [..gawk-script] I know it is running but from the debug/trace-facility in [asterisk..] no sign of activity can bee seen.

The code is very straight forward and I thought this would be easy but having no knowledge of Perl I cannot deduce what the trouble might be. What I suspect is that I lack some (trivial) code to "pump" the data back and forth. I have consulted (amongst other sources) perlipc and perlopentut but faild. What is it in theese descriptions that I have so far faild to understand.

Thanks / Bertil

The code looks like this:

package MyAGI; use strict; use base 'Asterisk::FastAGI'; sub agi_handler { my $self = shift; use IPC::Open2; local (*READ, *WRITE); my $pid = open2(\*READ, \*WRITE, "/path/and/bashscript.sh"); #here I tried various ways to "pump" data via *READ and *WRITE but + without success waitpid( $pid, 0 ); } 1;

In reply to Use of Open2() by wbook

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.