Re: writing to a named pipe (FIFO) fails
Re: writing to a named pipe (FIFO) fails
- Subject: Re: writing to a named pipe (FIFO) fails
- From: Adam Bell <email@hidden>
- Date: Tue, 21 Nov 2006 10:46:24 -0400
Assuming MacFifo is just a text file, you have to:
(you have to open a file to write to it, but not to read it)
set f to open for access macFifo with write permission (f is a
reference number)
try
write blah to f
on error
close access f
end
close access f
Adam
At 8:32 AM -0500 11/21/06, Cameron Hayne wrote:
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).
--
Cameron Hayne
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden