Re: Not able to write using Open2



Ashwin wrote:
Paul Lalli wrote:


Ashwin wrote:

SOrry, I missee one quatation
here is compiled code,
is there no way I can get it done with open2?

Get what done? I don't see anywhere in the code below in which you attempted to write to the process.


use warnings;
use strict;
use IPC::Open2;
use Cwd;

my $currentdir=cwd();
my $pid;
chdir ("/source/internal/") or die "Cannot Change Directory";
$pid = open2 (\*READ,\*MY_WRITE,"BuildInternal.pl") or die;

Here you open the process BuildInternal.pl, with a read filehandle READ and a write filehandle MY_WRITE


while (<READ>)

Here you begin reading from READ


{
 print $_;

Here you print the lines read from READ out to STDOUT


 }

print "MY_WRITE\n";

Here you print the string "MY_WRITE\n" out to STDOUT


while (<READ>)

Here you again read from READ


{
 print $_;

Here you again print the lines read from READ out to STDOUT


 }

close MY_WRITE;
close READ;

Here you close both filehandles.

What part of this code were you expecting to write anything to the
MY_WRITE filehandle?



sorry for missing the valid part
this part of the script

print "MY_WRITE\n"; should have been

print MY_WRITE "4\n";

Do you mean that your script contained print "MY_WRITE\n"; end you have now corrected it to print MY_WRITE "4\n"; and everything is OK now?

Or do you mean your script contained the latter all along but that instead of using copy & paste you are still retyping and making typing mistakes. In which case you still want help?

to clarify that value 4 need to be written in output handle and then  a
carridge return so that called script gets value as 4

IIRC on a Unix host, "\n" will emit a linefeed character, not the carriage-return character you mention. This might be causing you problems?


.



Relevant Pages

  • Re: exe file
    ... "Train my users"? ... An EXE, ... than a VBS script at doing just about anything. ... to convey the general difference between compiled code ...
    (microsoft.public.scripting.vbscript)
  • Re: Extract any URL from any string?
    ... with PHP (script vs. compiled code) ... but it's just good practice to do so (and increasing the ...
    (comp.lang.php)
  • Re: Problem with one perl script executing another, execution started by Apache httpd
    ... perl script that a) invokes a compiled program with one commandline ... Both the perl and the compiled code ...
    (comp.lang.perl.misc)
  • Re: Passing values between files
    ... > external to the wsf file that contains the function. ... - delete the function code from the <script> block it is contained in in ... And it is the compiled code in memory that is actually ...
    (microsoft.public.scripting.wsh)
  • Re: Scripter Studio v2.6 release
    ... it always save compiled code. ... These functions are intended to run a script faster. ... >> You can use SaveCodeToStream and LoadCodeFromStream methods of scripter ...
    (borland.public.delphi.thirdpartytools.general)