Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Waiting For Input

by Anonymous Monk
on Mar 04, 2013 at 06:46 UTC ( #1021591=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\Perl\\bin\\perl.exe", "perl temp.pl", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport();

I use the following code to invoke temp.pl from main.pl script. Temp.pl script runs and completes execution and then keeps on waiting ie does not end(The cmd cursor keeps blinking even after the Temp.pl script is run). Why??

Comment on Waiting For Input
Download Code
Re: Waiting For Input
by Anonymous Monk on Mar 04, 2013 at 08:11 UTC

    Temp.pl script runs and completes execution and then keeps on waiting ie does not end. Why?

    Because it is written that way. Maybe its waiting for input, like pause, or something else entirely, depends on what temp.pl does

    The cmd cursor keeps blinking even after the Temp.pl script is run

    cursors are designed to blink, its what they do

      No Temp.pl does not need any input nor any pause. Rather the main scipt conatins this:

      use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\Perl\\bin\\perl.exe", "perl Temp.pl", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $state = 1; while( <STDIN> ) { if( $state ) { $$ProcessObj->Suspend(); $state = 0; } else { $$ProcessObj->Resume(); $state = 1; } }

      How do i end both the scripts? i think it is the main script that keeps on waiting..

        So, when does the loop end?

        while( <STDIN> ) { ... }

        Maybe you want to print out some diagnostics at the end of Temp.pl and in your main script, to learn when a program starts or finishes, and when a program waits for input.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1021591]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-11-27 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (188 votes), past polls