fluxrad has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to write some perl code that basically "talks" to this program but IPC::Open2 seems to hang. I'm now trying something like the following:################## print "Once\n"; sleep 2; print "Input Please? "; $line = <STDIN>; chomp $line; print "You got: $line\n"; sleep 5; print "Twice\n"; ##################
This seems to hang too, with the script just waiting for input before doing *anything* Is there any way I can do some IPC without having to use the Expect module? Your advice is greatly appreciated!my $infile = "/tmp/foo.in"; my $outfile = "/tmp/foo.out"; my $binary = "./output.pl"; system("mkfifo $infile"); system("$binary < $infile > $outfile &"); open(DATA_OUT, ">$infile"); open(DATA_IN, "<$outfile"); while($line = <DATA_IN>) { chomp $line; print "Got $line\n"; if ($line =~ /\?/) { print DATA_OUT, "blah\n"; } } close(DATA_OUT); close(DATA_IN); system("rm $infile $outfile");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IPC Help
by pbeckingham (Parson) on Jun 25, 2004 at 01:43 UTC | |
|
Re: IPC Help
by etcshadow (Priest) on Jun 25, 2004 at 03:53 UTC | |
|
Re: IPC Help
by NetWallah (Canon) on Jun 24, 2004 at 22:48 UTC | |
by fluxrad (Initiate) on Jun 24, 2004 at 23:40 UTC |