home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5279 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.5 KB  |  51 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!stanford.edu!rock!cole
  3. From: cole@concert.net (Derrick C. Cole)
  4. Subject: Re: Help with named pipes
  5. Message-ID: <1992Aug12.192105.5316@rock.concert.net>
  6. Sender: news@rock.concert.net
  7. Organization: MCNC Data Operations
  8. References: <3310@ra.nrl.navy.mil> <1992Aug12.162224.3119@rock.concert.net> <1992Aug12.163401.5091@news.eng.convex.com>
  9. Date: Wed, 12 Aug 1992 19:21:05 GMT
  10. Lines: 39
  11.  
  12. In article <1992Aug12.163401.5091@news.eng.convex.com> tchrist@convex.COM (Tom Christiansen) writes:
  13. >From the keyboard of cole@concert.net (Derrick C. Cole):
  14. >:You're right!  It should be while(1).  However, open() still doesn't seem to
  15. >:return to enter the read loop.
  16. >
  17. >For open on a named pipe to return, there must be both a reader
  18. >and a writer.
  19.  
  20. Greetings, Tom!
  21.  
  22. Ok.  The following works when there's a writer on the other end:
  23.  
  24. #!/usr/local/bin/perl
  25.  
  26. ($pipe) = @ARGV;
  27. $pipe = "/var/log/modemlog" unless $pipe;
  28.  
  29. if (-p $pipe) {
  30.    open(FIFO, "$pipe") || die "can't open\n";
  31.    while (<FIFO>) {
  32.       read(FIFO, $buf, 120);
  33.       chop($buf);
  34.       print "|$buf|\n";
  35.    }
  36. }
  37.  
  38. Now, 120 is an arbitrary number out of the air.  What I'd really like is for
  39. read() to place in $buf a null-terminated string as written by the other end,
  40. and not just 120 characters.  Am I completely blind, is there a way to do
  41. this, neither, or both?
  42.  
  43. Thanks for the help!
  44. Derrick
  45.  
  46. -- 
  47. "GCC 2.0 is to C as SVR4 is to Unix."
  48.                        -- Dick Dunn
  49. ======
  50. Derrick Cole                                  MCNC Center for Communications
  51.