Cannot write to fifo

Cannot write to fifo

am 29.08.2011 16:53:54 von Ramprasad Prasad

--000e0cd18720616a0904aba61054
Content-Type: text/plain; charset=ISO-8859-1

How can I open multiple FIFO files in perl and print to them simultaneously

I tried a simple script does not work


#!/usr/bin/perl
use strict;

use IO::File;
$|=1;
system("rm -f /tmp/fifo1;mkfifo /tmp/fifo1");
open (OUT,"> /tmp/fifo1") || die;
for (0 .. 10){
print "Hi $_\n";
print OUT "Hi $_\n";

}
close OUT;

--000e0cd18720616a0904aba61054--

Re: Cannot write to fifo

am 29.08.2011 18:58:01 von Jim Gibson

On 8/29/11 Mon Aug 29, 2011 7:53 AM, "Ramprasad Prasad"
scribbled:

> How can I open multiple FIFO files in perl and print to them simultaneously

The program below only opens one FIFO. Is your problem related to opening
multiple FIFOs or opening one FIFO?

> I tried a simple script does not work

"Does not work" is not a helpful description of the problem. It would help
if you could tell us exactly what happens when you run your program. Cut and
paste the actual error messages, if any, that you are getting into your
post.

>
>
> #!/usr/bin/perl
> use strict;
>
> use IO::File;
> $|=1;
> system("rm -f /tmp/fifo1;mkfifo /tmp/fifo1");
> open (OUT,"> /tmp/fifo1") || die;
> for (0 .. 10){
> print "Hi $_\n";
> print OUT "Hi $_\n";
>
> }
> close OUT;

This program creates, opens, and writes to a FIFO. This program should block
on writing to the FIFO until there is a corresponding reading process that
reads from the FIFO. Is there another program reading the FIFO?

See 'perldoc perlipc' and search for "Named Pipes". You will learn there
that there is no need to create a new process to create the FIFO, as you can
use the POSIX module and its mkfifo function.



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/