Hi,
I have some problems with bidirectional communication with an .exe application using perl.
Here is what I am trying to do : I have a c++ console application which asks for a list of values un the standard input, multiply all the elements of the list by a value and print the new list on the standard output. (This is only an example to get me started actually)
Then, I am trying to run the application from a perl script, write to the application some values using the script, and read the new values returned on the standard output from the application.
Here is my perl code for now :
#!/usr/bin/perl use IPC::Open2; my $toExec = "testfigure.exe"; my @xList = (1,2,3,4,5); my $ret; local(*WR, *RD); my $pid = open2(\*RD, \*WR, $toExec); my $length = @xList; print WR "$length\n"; foreach my $xVal (@xList){ print WR "$xVal\n"; } print WR "3\n"; while($ret = <RD>){ print; } waitpid($pid,0);
And here is the problem I'm running into : I cannot read from the application. The part while($ret = <RD>) does not work, I'm always getting an empty $ret (no reading is done). Though, I can write to the application and it does print @xList multiply by 3 on the screen. I have looked all the examples I could find on the web, and read all the perlipc manpage but there is nothing about such a problem. I am using Windows 2000 professional (maybe it is a known bug).
If anyone has any idea why this code does not work properly, I would really appreciate the help !
Thanks to you2006-07-23 Retitled by g0n, as per Monastery guidelines
Original title: 'Bidirectionnal Communication with Another Process'
In reply to Bidirectional Communication with Another Process by duc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |