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: Help with named pipes
- Message-ID: <1992Aug12.140317.1603@rock.concert.net>
- Sender: news@rock.concert.net
- Organization: MCNC Data Operations
- Date: Wed, 12 Aug 1992 14:03:17 GMT
- Lines: 48
-
- Greetings!
-
- I would like to get this piece of C code
-
- if ((np = open(pipefile, O_RDONLY)) < 0) {
- fprintf(stderr, "%s: can't open %s\n", progname, pipefile);
- exit(3);
- }
-
- for (;;) {
- bzero(buf, sizeof(buf));
- read(np, buf, sizeof(buf));
- buf[strlen(buf)-1] = '\0';
- parse();
- if (INTFLAG) {
- close(np);
- exit(0);
- }
- }
-
- to function properly in Perl. This is what I've come up with so far:
-
- #!/usr/local/bin/perl
-
- ($pipe) = @ARGV;
- $pipe = "/var/log/modemlog" unless $pipe;
-
- if (-p $pipe) {
- open(FIFO, "$pipe") || die "can't open $pipe\n";
- while (<>) {
- read(FIFO, $buf, 120);
- print "$buf";
- }
- }
-
- and it don't work. Apparently, open() doesn't return, and the loop is never
- reached.
-
- Any and all help will be greatly appreciated!
-
- Thanks,
- Derrick Cole
-
- --
- "It's good to see a Democrat blow something besides the election."
- -- Arsenio Hall on Bill Clinton's sax set with The Posse
- ======
- Derrick Cole MCNC Center for Communications
-