Ok this question came to me after reading
Interprocess Communication.
That question covered something I have been trying to do for a long time, namely the ability to feed information to a process that won't accept standard shell input redirection. i.e. telnet ( when it asks for the password )
So I attempted to implement the Open2 code given in response
here, and ran into this problem:
The first time I attemt to read from the read filehandle, the program blocks until broken. I tried this with other programs as well, and the same thing occurs on any program that requires user input. It works fine on programs like hostname that do not require user input. Here is the code that I am using:
#!/usr/local/bin/perl
use IPC::Open2;
$SIG{CHLD} = sub { $i = 1 };
local ( *RD, *WR );
print "Opening $ARGV[0]\n";
my $child = open2(\*RD, \*WR, "$ARGV[0]") || die "couldn't open $ARGV[
+0]";
print "Finished opening $ARGV[0]\n";
$i = 0;
while (1) {
$prompt = <RD>;
print $prompt;
last if ( $i = 1 );
$cmd = <STDIN>;
$cmd1 = "'".$cmd."'";
print WR "$cmd";
}
NOTE: The code is not complete, but I wasn't going to bother adding things like alrm handlers and whatnot until I knew that this would at least work in a normal situation.