Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

writing to a named pipe (FIFO) fails



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: http://lists.apple.com/mailman/options/applescript-users/email@hidden Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.