stdin / stdout revisited: dual pipes 
Author Message
 stdin / stdout revisited: dual pipes

I have an interactive application that I'd like to write a PERL script
to both read it's STDOUT and also send input via STDIN.  This is
documented in the FAQ
( http://www.*-*-*.com/ )

but when it comes right down to it, the only advice given is:

    At the risk of deadlock, it is theoretically possible to use a
    fork, two pipe calls, and an exec to manually set up the two-way
    pipe.  (BSD system may use socketpair() in place of the two pipes,
    but this is not as portable.)  The open2 library function distributed
    with the current perl release will do this for you.

Questions:

1) My PERL 4.0 distribution apparently does not have open2, at
   least a grep in my /usr/lib/perl directory would indicate.  How can
   I get this library function?

2) In the absence of the lib function, how would one construct the
   fork, two pipes, and exec to set up the two-way pipe?  (my program
   is entirely based on STDIN by line and STDOUT by line)

Thanks,

Mike

*------------------------------------------------------------*
| Michael Stangel    |  "Her eyes were cold and harsh, which |
| WWW Developer      |   made them tough to chew."           |
| Eli Lilly and Co.  |                                       |

*------------------------------------------------------------*



Tue, 14 Apr 1998 03:00:00 GMT  
 stdin / stdout revisited: dual pipes

Quote:

>  I have an interactive application that I'd like to write a PERL script
>  to both read it's STDOUT and also send input via STDIN....

I found the answer to my own question, in the University of Florida
archives:  
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/scripts/process-handling/STDIN.ST...

Mike

*------------------------------------------------------------*
| Michael Stangel    |  "Her eyes were cold and harsh, which |
| WWW Developer      |   made them tough to chew."           |
| Eli Lilly and Co.  |                                       |

*------------------------------------------------------------*



Tue, 14 Apr 1998 03:00:00 GMT  
 stdin / stdout revisited: dual pipes

Quote:


> >  I have an interactive application that I'd like to write a PERL script
> >  to both read it's STDOUT and also send input via STDIN....

> I found the answer to my own question, in the University of Florida
> archives:  
> ftp://ftp.cis.ufl.edu/pub/perl/CPAN/scripts/process-handling/STDIN.ST...

Actually that's the recently announced globally mirrored Comprehensive
Perl Archive Network and it is indeed a wonderful thing.

Many hours have gone into giving things good names like

  CPAN/scripts/process-handling/STDIN.STDOUT.connection.pipe

I guess I'll have to start answering questions with "and the CPAN has ..." :)

Tim.



Wed, 15 Apr 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. stdin/stdout pipes to a program

2. Experiments fail for stdin/stdout piping - help!

3. pipes and STDIN/STDOUT

4. tee revisited: dup STDOUT to a file but still get output from both

5. revisiting "pod style comments revisited"

6. Transferring STDIN/STDOUT to user & back

7. Can you redirect STDIN/STDOUT on the fly ?

8. Problem with STDIN, STDOUT, control character

9. duping of stdin and stdout

10. Opening Stdin and Stdout to process

11. Socket <> Stdin/Stdout

12. synchronistaion of STDIN with redirected STDOUT

 

 
Powered by phpBB® Forum Software