Message Boards Message Boards


OpenRead does not read from a pipe?

Posted 9 years ago
1 Reply
0 Total Likes

Dear All,

It seems like such a simple problem, yet I can't crack it: Has anyone managed to get OpenRead to read from a simple Unix fifo pipe?

I do:

Run["mkfifo /tmp/test.fifo"]

which creates a pipe for me just fine. When I attempt to open it with


Mathematica returns with:

OpenRead::noopen: "Cannot open "/tmp/test.fifo"

It does not matter if something writes to the pipe when the OpenRead is executed.

It seems I can do something ugly as OpenRead["!cat /tmp/test.fifo"], but that misses the point, and as a bonus, it blocks the pipe and I can't write to the pipe.

Any ideas?

Thank you!


PS I'm running Mathematica 10 on OSX 10.9.5.

POSTED BY: Pawel Osiczko

(Truth in advertising... I don't know much about this ;-) )

Reading the documentation where it says

On systems that support pipes, OpenRead["!command"] runs the external program specified by command, and opens a pipe to get input from it.

perhaps that suggests that you need to open the pipe directly in the argument of OpenRead rather than first creating it using Run?

When I try this it seems to work:

In[3]:= OpenRead["!mkfifo /tmp/test.fifo"]

Out[3]= InputStream["!mkfifo /tmp/test.fifo", 237]
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract