I am trying (but failing) to write to a FIFO or named pipe (http://
en.wikipedia.org/wiki/Named_pipe) from AppleScript.
Here's an example script (the named pipe at "/Users/myusername/
mystuff/myfifo" is set up previously in a Terminal window):
------------------------------------------------------------------------
----
set fifo to "/Users/myusername/mystuff/myfifo"
do shell script "echo AAA > " & fifo
set macFifo to POSIX file fifo
try
write "BBB" to macFifo
on error errString number errNum
display alert errString & " (" & errNum & ")"
end try
try
set fd to open for access macFifo with write permission
write "CCC" to fd
close access fd
on error errString number errNum
display alert errString & " (" & errNum & ")"
end try
------------------------------------------------------------------------
----
The 'do shell script' works fine and the "AAA" gets transmitted to
the named pipe.
But the two attempts ("BBB" & "CCC") to write to the named pipe
using 'write' both fail with error -36 which is "ioErr (-36): I/O
error (bummers)".
Note that if I change the above example to refer to a regular file,
it all works fine.
Is there any way to write to a named pipe (FIFO) using 'write' in
AppleScript?
I want to avoid the use of 'do shell script' for reasons of
performance (each 'do shell script' seems to take about 0.1 second
and in my AppleScript I will be doing thousands of writes to the
named pipe).