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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!stanford.edu!rock!cole
  3. From: cole@concert.net (Derrick C. Cole)
  4. Subject: Help with named pipes
  5. Message-ID: <1992Aug12.140317.1603@rock.concert.net>
  6. Sender: news@rock.concert.net
  7. Organization: MCNC Data Operations
  8. Date: Wed, 12 Aug 1992 14:03:17 GMT
  9. Lines: 48
  10.  
  11. Greetings!
  12.  
  13. I would like to get this piece of C code
  14.  
  15.    if ((np = open(pipefile, O_RDONLY)) < 0) {
  16.       fprintf(stderr, "%s: can't open %s\n", progname, pipefile);
  17.       exit(3);
  18.    }
  19.  
  20.    for (;;) {
  21.       bzero(buf, sizeof(buf));
  22.       read(np, buf, sizeof(buf));
  23.       buf[strlen(buf)-1] = '\0';
  24.       parse();
  25.       if (INTFLAG) {
  26.          close(np);
  27.          exit(0);
  28.       }
  29.    }
  30.  
  31. to function properly in Perl.  This is what I've come up with so far:
  32.  
  33. #!/usr/local/bin/perl
  34.  
  35. ($pipe) = @ARGV;
  36. $pipe = "/var/log/modemlog" unless $pipe;
  37.  
  38. if (-p $pipe) {
  39.    open(FIFO, "$pipe") || die "can't open $pipe\n";
  40.    while (<>) {
  41.       read(FIFO, $buf, 120);
  42.       print "$buf";
  43.    }
  44.  
  45. and it don't work.  Apparently, open() doesn't return, and the loop is never
  46. reached.
  47.  
  48. Any and all help will be greatly appreciated!
  49.  
  50. Thanks,
  51. Derrick Cole
  52.  
  53. -- 
  54. "It's good to see a Democrat blow something besides the election."
  55.                        -- Arsenio Hall on Bill Clinton's sax set with The Posse
  56. ======
  57. Derrick Cole                                  MCNC Center for Communications
  58.