in reply to Use of Open2()
Dear Monks and other seekers!
This is my own reply to the previous questions entitled "Connect gawk via perl to fastagi and asterisk" and "Use of Open2()".
After having looked near and far on the web I finally got back to where I started and must confess that my own question "what have I faild to understand" would better be phrased "what have I faild to read". When I consulted perlfoundations manual on IPC::Open2 closely and the concept of "bareword file handles" I saw an (of me) untested path and after trying I concluded it was the right one.
The part of the script reading
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 );
should go like this
use IPC::Open2; my $pid = open2(">&STDOUT", "<&STDIN", "/path/and/bashscript.sh"); #bashscript in its turn containing a gawk-script. waitpid( $pid, 0 );
This solves my immediate problems. No "pumping" or otherwise is needed for the communication. It now appears to function correctly between both ends of the dataflow.
Perl is without doubt a powerful language but there are many details to consider for the novice. Therfore I welcome all comments regarding its accuray or usefulness.
Kind regards to you all / Bertil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Revised: Use of Open2()
by CountZero (Bishop) on Nov 26, 2009 at 07:14 UTC |