JavaFan++
Thanks for the quick help. I've modified the test script (see below) and it now works as expected.
One question though. Using the tail -f line below causes the script to fail, reverting to the cat line makes it work. I don't understand why?
Thanks
-Craig
use strict;
use warnings;
use FileHandle;
# Create named pipe...
my $pipe = "/tmp/mypipe";
system("ksh -c 'if [ ! -p $pipe ]; then mkfifo $pipe; fi'");
# Setup input process...
open(IN, '|-', "cat - > $pipe") || die "Can't open IN process: $!";
IN->autoflush(1);
# Setup output process...
#open(OUT, '-|', "tail -f $pipe") || die "Can't open out process: $!";
open(OUT, '-|', "cat $pipe") || die "Can't open out process: $!";
OUT->autoflush(1);
my $i=0;
print STDERR "Sending input...\n";
print IN "This is message $i\n";
# Read output...
print "Reading...\n";
my $line;
while($line = <OUT>) {
$i++;
print $line;
print IN "This is message $i\n";
sleep 1;
}
|