Topic: Named Pipes......Understanding use from Flash
Based on following sample code:
// Launch a program which is likely to remain resident, and will not be
// terminated on close. Should not be used for anything that will block!
_pipeDaemon = ASnative(5,190);
res = _pipeDaemon( "/mnt/usb/bin/readbot >/mnt/usb/readbot.log 2>/mnt/usb/readbot.err &" );
trace( "daemon launch result = " + res );
// Open a pipe for reading
_pipeOpen = ASnative(5,191);
g_handle = _pipeOpen( "tail -f /mnt/usb/readbot.err", "r" );
trace( "pipe open result = " + g_handle );
// Set input event notification handler for a pipe which was opened for reading.
// Call again with an empty string to switch back to normal reading.
// When this is active attempts to read will always return an empty string.
this.myListener = Object();
this.myListener.onEvent = function( status, comments )
{
if (status == "data")
{
trace( "got myListener.DataReceived.onEvent(" + comments + ")" );
}
else
{
// only data and eof supported
trace( "status = " + status );
}
};
ExtendedEvents.DataReceived.addListener( myListener );
trace( "Switching to event notification for handle " + g_handle );
_pipeSetInput = ASnative(5,192);
_pipeSetInput( g_handle, "DataReceived" );
// Read from a pipe previously opened for reading. If nothing available returns empty string.
_pipeRead = ASnative(5,193);
s = _pipeRead( g_handle );
if (s != undefined && s != "")
{
trace( "data=" + s );
}
// Write to a pipe previously opened for writing.
_pipeOpen = ASnative(5,191);
_pipeWrite = ASnative(5,194);
writeTest = _pipeOpen( "./wptest.sh >wptest.out", "w" );
trace( "Write handle result = " + writeTest );
_pipeWrite( writeTest, "first_line of test\n" );
// Close a pipe previously opened for reading or writing
_pipeClose = ASnative(5,195);
_pipeClose( writeTest );
I am still trying to understand the parameters passed to the pipe opening call. It seems you do not name the pipe file, but seem to need to execute a process to get the handle (I think).
Looking at the ,write to a pipe, sample code, it seems I need a shell script that redirects its output to the named pipe.
Do I really need to provide a shell script along with the Flash program just to write to a named pipe?
Also
I noticed a process (using ps) that shows the following binary /usr/bin/chumbpipe. It seems to be able to take a sending and receiving named pipes as parameters. Can I use this in my Flash program to read and write to a pipe? and how do I use it?
Thanks
Mark