CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Win32 Programming Help:
Problem with open2 & open3 in WinXP.


New User

Nov 4, 2009, 2:45 AM

Post #1 of 3 (8172 views)
Problem with open2 & open3 in WinXP. Can't Post

Hello, i have a problem with open2 and open3. Open work succesfully.

I porting my perl script from Linux to Windows. I realize many test and dont find any problem (executing calc.exe, perl script, etc) but three days ago problem starting with one executable.

The executable is a simulation program. It read a file specifiqued in command line parameter and write output files.

I used open3:
$childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, $cmd, @args);

The program start and freeze quickly. ¿Sleep? ¿Waiting by syscall? i dont know.

Screen capture of the three scenarios:
1) Capture when start and blocks (open2 and open3).
$pid = open2(\*CHLD_OUT, \*CHLD_IN, 'c:\madymo70.exe');
print "EXE\n"; #this dont show
print "FINAL\n";
(File: block on start.jpg)

2) Capture when start correctly (open)
$pid = open(HANDLE, "|C:/madymo70.exe|");
#PROBLEM: ¡¡¡¡¡¡¡continue when program finnish!!!!!!!!
print "EL PID ES: $pid";
print "FIN\n";
(File: ok when used open.jpg)
3) Win32::Process::Create work ok but ¿How could i capture stdout and stderr?.

I need start program in background while perl script continue. Perl script check if program finish and connect to database.

Somebody have an idea why it work don't fine?

(This post was edited by julmss on Nov 4, 2009, 5:54 AM)
Attachments: ok when used open.jpg (61.1 KB)
  block on start.jpg (51.9 KB)

Veteran / Moderator

Nov 4, 2009, 8:44 AM

Post #2 of 3 (8159 views)
Re: [julmss] Problem with open2 & open3 in WinXP. [In reply to] Can't Post

Have you tried passing references or lexical vars?


$childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, $cmd, @args);


$childpid = open3(\*HIS_IN, \*HIS_OUT, \*HIS_ERR, $cmd, @args);


open3($writer, $reader, $error, $cmd, @args);

New User

Nov 4, 2009, 9:28 AM

Post #3 of 3 (8154 views)
Re: [FishMonger] Problem with open2 & open3 in WinXP. [In reply to] Can't Post

Thank you for your post.

Yes,I tried it.

After many many hours, open2 and open3 work ->IF I READ TWO LINES FROM STDOUT<-:

$program="C:/Madymo/madymo_70/win32p/bin/madymo70.exe c:/W62_DAB.xml";
($reader, $writer) = (IO::Handle->new, IO::Handle->new);
open2($reader, $writer, $program);
print "----> ".<$reader>."\n";
print "----> ".<$reader>."\n";


This work!

I don't understand. Why if i read two lines or more from stdout the process continue? I probe to write stdin (the process dont read stdint) but not read from stdout.

Very thank you


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives