home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!mentor.cc.purdue.edu!noose.ecn.purdue.edu!lucky.ecn.purdue.edu!newlin
- From: newlin@lucky.ecn.purdue.edu (Johnny N.)
- Newsgroups: comp.lang.perl
- Subject: Re: Pipe, et al, what am I doing wrong?
- Keywords: pipe, fork
- Message-ID: <newlin.712265408@lucky.ecn.purdue.edu>
- Date: 27 Jul 92 19:30:08 GMT
- References: <1992Jul27.115715.21337@neptune.inf.ethz.ch>
- Sender: news@noose.ecn.purdue.edu (USENET news)
- Organization: Purdue University Engineering Computer Network
- Lines: 33
-
- weingart@inf.ethz.ch (Tobias Weingartner) writes:
-
- >Here is a small script, that seems to hang. What am I doing
- >wrong? A ps shows that the child is waiting for the parent
- >to `wait` on it. Also, the parent seems to hang because it
- >does not get EOF.
-
- >Can anyone give me a working example of this?
-
- sure.
-
- --------- original script deleted -------------
- try this:
-
- #!/usr/local/bin/perl
-
- @data= ();
-
- die "can't fork: $!" unless defined ($pid=open (CHILD, "-|"));
- if ($pid == 0) {
- exec ('/bin/cat/', '/etc/passwd');
- }
- else {
- open (STDIN, "<&CHILD");
- while (<STDIN>) {
- push (@data, $_);
- print ".";
- }
- print "\nLines: $#data\n";
- }
-
-
- -John
-