home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!stanford.edu!rock!cole
- From: cole@concert.net (Derrick C. Cole)
- Subject: Re: Help with named pipes
- Message-ID: <1992Aug12.192105.5316@rock.concert.net>
- Sender: news@rock.concert.net
- Organization: MCNC Data Operations
- References: <3310@ra.nrl.navy.mil> <1992Aug12.162224.3119@rock.concert.net> <1992Aug12.163401.5091@news.eng.convex.com>
- Date: Wed, 12 Aug 1992 19:21:05 GMT
- Lines: 39
-
- In article <1992Aug12.163401.5091@news.eng.convex.com> tchrist@convex.COM (Tom Christiansen) writes:
- >From the keyboard of cole@concert.net (Derrick C. Cole):
- >:You're right! It should be while(1). However, open() still doesn't seem to
- >:return to enter the read loop.
- >
- >For open on a named pipe to return, there must be both a reader
- >and a writer.
-
- Greetings, Tom!
-
- Ok. The following works when there's a writer on the other end:
-
- #!/usr/local/bin/perl
-
- ($pipe) = @ARGV;
- $pipe = "/var/log/modemlog" unless $pipe;
-
- if (-p $pipe) {
- open(FIFO, "$pipe") || die "can't open\n";
- while (<FIFO>) {
- read(FIFO, $buf, 120);
- chop($buf);
- print "|$buf|\n";
- }
- }
-
- Now, 120 is an arbitrary number out of the air. What I'd really like is for
- read() to place in $buf a null-terminated string as written by the other end,
- and not just 120 characters. Am I completely blind, is there a way to do
- this, neither, or both?
-
- Thanks for the help!
- Derrick
-
- --
- "GCC 2.0 is to C as SVR4 is to Unix."
- -- Dick Dunn
- ======
- Derrick Cole MCNC Center for Communications
-