Ah, but it works like i think it does !

Here 's tt.pl :

use strict ; use warnings; use Win32::Job ; my $job = Win32::Job->new; my $tmout = 20 ; my %opt = ( stdout => 'out.txt' , stderr => 'err.txt' ) ; $job -> spawn ( 'c:/perl/bin/perl.exe', 'perl sp.pl',\%opt) ; my $ok=$job->run($tmout, 0) ; $ok ? print "ended before $tmout sec" : print "had to kill it" ;
And here the spawned process :
#!perl use warnings; use strict ; select STDERR ; $|=0 ; select STDOUT ; $|=0 ; my $i = 0 ; while ($i < 5 ) { print STDOUT "Do the hammerlock\n" ; print STDERR "Do the hammerlock you turkeynecks !\n" ; sleep 2; $i++ ; }
Here is the out.txt file :
Do the hammerlock Do the hammerlock Do the hammerlock Do the hammerlock Do the hammerlock
And the err.txt :
Do the hammerlock you turkeynecks ! Do the hammerlock you turkeynecks ! ... (uh, well, you get it ... )
With your example it needs print \"ran ok\" and the full path to the perl binary, but test.out is still empty, i can't figure out why ... Something lame with the windows command line, maybe ...

Anyway Win32::Job does it, as the above example shows, and without much of hassle. It gives you the handler feature if you need it and "job" control and all other windows gimmicks.

zlr
well, now let's try to understand this other use threads heavy wizardry stuff :)


In reply to Re^5: Win32 capturing output from a process that may hang by ZlR
in thread Win32 capturing output from a process that may hang by Random_Walk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.