Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > print to STDOUT works but FH1 does not with FIFO named pipe

Reply
Thread Tools

print to STDOUT works but FH1 does not with FIFO named pipe

 
 
gnari
Guest
Posts: n/a
 
      07-14-2004
"Rocky" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) g...
> On Wed, 14 Jul 2004 14:11:44 -0400, Paul Lalli wrote:
>


[reading from pipe to files]
>
> My mistake. I left the FH1 and FH2 out of the posted code. When I run
> this script and just print it to standard out the data will stream
> perfectly as it comes in from the FIFO. If I print it to FH1,FH2 and tail
> -f the output files I get nothing. That, I guess, is what I should have
> said from the beginning


yes, you should have mentioned that you test this with grep.

you are not seing any output because you are not waiting long enough.
the data is still in file or pipe buffers when you probably interrupt
your program.

gnari




 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      07-15-2004
Rocky <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> On Wed, 14 Jul 2004 15:10:58 -0400, Paul Lalli wrote:
>
> > On Wed, 14 Jul 2004, Rocky wrote:
> >
> >> My mistake. I left the FH1 and FH2 out of the posted code. When I run
> >> this script and just print it to standard out the data will stream
> >> perfectly as it comes in from the FIFO. If I print it to FH1,FH2 and tail
> >> -f the output files I get nothing. That, I guess, is what I should have
> >> said from the beginning

> >
> > As I said in my last post, show us your code. We can't debug something on
> > your assertion that it should work. We have to see the actual code you're
> > using. Show us the code that you think should work, but does not.
> >
> > Paul Lalli

>
> so posted sir.
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> $| = 1;
> #open(FH3,"</var/run/syslogdpipe") or die "$!\n";
> open(FH3,"</storage/tempmail") or die "$!\n";
> open(FH1,">./mx0out") or die "$!\n";
> open(FH2,">./mx1out") or die "$!\n";
> while (<FH3>)
> {
> my $line = $_;
> if ($line =~ /^.*svr-linux.*$/)
> {
> print FH1 "mx00 $line\n";
> }
> elsif ($line =~ /^.*192\.168.*$/)
> {
> print FH2 "mx01 $line\n";
> }
> }


If you want to see each line as it appears in the output files, turn
on auto-flushing for them. Add these lines after the last "open":

do { select $_; $| = 1 } for \ *FH1, \*FH2;
select STDOUT;

Another potential problem is that you must wait for the program to
start before you run "tail -f" on the output file(s). If you don't,
"tail" will try to follow the last output file while the program
has created a new one.

Anno
 
Reply With Quote
 
 
 
 
MichiganBob
Guest
Posts: n/a
 
      07-17-2004
Rocky Allen wrote:

> It might be faster just to read the book.
>

You're free to do so.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
any body having complete code for a synchronous FIFO or know a link where FIFO codes are available chaitu VHDL 1 06-01-2007 03:45 AM
any body having complete code for a synchronous FIFO or know a link where FIFO codes are available chaitu VHDL 1 05-31-2007 03:31 PM
any body having complete code for a synchronous FIFO or know a link where FIFO codes are available chaitu VHDL 0 05-31-2007 02:28 PM
Problems redirecting STDOUT (NOT sys.stdout) to a pipe. Elad Python 0 03-19-2006 01:30 PM
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM



Advertisments