Feb 17, 2011, 7:05 AM
Post #1 of 1
Piping for IPC
I've got two scripts that I've written and I'd like to just send some simple messages from one to the other. I figured the easiest way to do this would be to just open a pipe from one script to the other so in the parent script I'm doing:
open(my $CAN_PIPE, "| perl runCAN.pl ");
print($CAN_PIPE, " DCAN21\n");
print($CAN_PIPE, " run \n");
print($CAN_PIPE, " q \n");
and in runCAN.pl I try to read in data using a while(<>):
$/ = "\n";
#case statement to deal with input...
The child script (runCAN.pl) works great if I call it by itself from the command line; it does everything I tell it and seems to read from STDIN just fine. However, when I call runCAN from the parent script it appears that the child is indeed excuted (debug print statements outside the while(<>) are executed) but the while(<>) which actually interprets the commands from teh STDIN pipe never runs.
I apologize in advance if this is n00b question. I searched around and couldn't find the answer. I spend most of my time doing embedded C for micros, so you'll have to forgive me.
Thanks in advance for the help,