wbook has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks! Being a novice to many things I wonder if somebody could show me the right direction.

1) I have a functioning gawk-program presently running as an agi-script in an asterisk server.

2) I want to run it from a fastagi-server written i perl. (asterisk and fastagi comunication over tcp-ip)

3) I want to call the gawk-progr. from within the perlscript and thereby (hopefully) connecting the gawk-script stdin and stdout in such a manner that the gawk-program can communicate back and forth with the asterisk server via the perl-script.

QUESTION: Is this possible? Thanks

  • Comment on Connect gawk via perl to fastagi and asterisk

Replies are listed 'Best First'.
Re: Connect gawk via perl to fastagi and asterisk
by jmcnamara (Monsignor) on Nov 20, 2009 at 09:50 UTC

    Perl comes with an a2p awk-to-perl utility that can be used to translate an awk program to Perl.

    It may not work with a full gawk program however and the resulting Perl that it produces isn't very pretty.

    There is a module called Inline::Awk that uses a2p as a back end to allow you to include your awk functions or entire program in a Perl program.

    It will only work if your program compiles with a2p and even them it isn't a great solution.

    Otherwise, you could just open a pipe to your gawk program/process from within your Perl program. See perlopentut for some examples. Or perhaps someone else here with FastCGI experience can point you in the direction of doing it efficiently in that environment.

    --
    John.