I need to execute a program, write some data to its stdin and then read its stdout. A little research has yieled that
open FILE, "| $prog |"; does not work for some less than obvious reasons.
Gladly, perl comes with IPC::Open2, which allows you to direct the STDIN and STDOUT of an executed program and let your script control them. But, for some reason my code isn't working. Here is is:
#!/usr/bin/perl
use IPC::Open2;
print open2(\*BOIN, \*BOOUT, "cat");
print BOIN "proclist\n";
print BOIN "quit\n";
close BOIN;
while (<BOOUT>) {
print;
}
close BOOUT;
Prints nothing. Any thoughts?