named pipes using mknod

named pipes using mknod

Post by Luke A. Kanie » Thu, 10 Feb 2000 04:00:00



So what use exactly is a named pipe when created using mknod?  

I ask because I am trying to write something such that I can read (as
opposed to execute) a file, and the script I wrote will be executed and
its output will be read from the file.  

As an example, say my script is 'run'.  I am wondering if I could use
mknod to create a named pipe, 'pipe', such that when I ran something like:

cat pipe

'run' would be executed, and the result would be that I would cat the
output of 'run' to the terminal.

It doesn't seem like this is possible, but I don't know much about mknod
and its uses.  Does anyone know of a way that I might do this (that is,
run a script just by reading a file)?  Also, is there a good resource for
info on mknod, since its man page is about two lines long?

-----------
He was just little!  What's the point of putting him here and taking
him so soon?  It's either mean or it's arbitrary, and either way I've
got the heebie-jeebies.
                -- Calvin

 
 
 

named pipes using mknod

Post by Luke A. Kanie » Thu, 10 Feb 2000 04:00:00




> :(that is, run a script just by reading a file)?  Also, is there a
> :good resource for info on mknod, since its man page is about two
> :lines long?

> six* different readers.  (In that case you could do something like

> mkfifo /tmp/pipe
> program1 >/tmp/pipe &
> reader1 </tmp/pipe &
> reader2 </tmp/pipe &
> ...
> reader16 </tmp/pipe &
> )

Okay, this basically gets me what I want.  The only problem I am having,
though, is that I want to reader to read one segment and then return, but
I want to writer to always be running, and I can't get that to work the
way I want.

Here is an example of what my writer looks like (perl):

while (1)
{
        open OUT, "> /tmp/pipe";
        $rand = rand $#ar;
        print OUT "$ar[$rand]\n";
        close OUT;

Quote:}

This gives weird results.  It basically just prints a random number of
segments of the array, then closes the pipe.  In other words, the reader
sees some random number of text outputs, then exits.  The writer never
quits on me, and I can run the reader any number of times, each time
getting a different number of outputs.

If I remove the while loop, and just put an exec($0) at the end, then the
problem is fixed, but requires more processing for each read.

Can you think of a way that I can tell the reader to stop reading?  I
figured closing the pipe would work, but apparently not.

(In case you have not figured it out, I am only using this to randomly
generate signatures.  Not very useful, but an interesting problem.)

-----------
He was just little!  What's the point of putting him here and taking
him so soon?  It's either mean or it's arbitrary, and either way I've
got the heebie-jeebies.
                -- Calvin

 
 
 

1. named pipes with mknod

I am having trouble creating named pipes with mknod.  I would like to
enable my .plan file to do conditional operations for an informational
application that I have in mind.  I would be appreciative if someone
could post or e-mail me an example of linking an executable to a .plan
finger file.

Thank you,

Kevin Huber
CPE Student

2. network (ip) problems with redhat

3. Named pipes and mknod...

4. smail configuration - please help!!!

5. Named pipe with mknod

6. Installationproblem on 5.0.5 with AHA2940AU

7. Any compatibility between Unix Named Pipes and NT Named Pipes??

8. aol under linux?

9. Q: using named pipe in kernel-module2

10. Using Named Pipes

11. client / server using named pipes

12. named pipes versus the unnamed pipeline using "|"

13. Using c++ ifstream with named pipe