Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
XP is just a number
 
PerlMonks  

Re: Using Win32::Process to prevent timeouts

by rchiav (Deacon)
on Feb 04, 2002 at 22:14 UTC ( [id://143343]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Using Win32::Process to prevent timeouts

The only time I've ever used Win32::Process is when I wanted to test whether I could connect to a remote resigtry. What would happen is that on some machines, it would hang and the script would basically stop.

I'm not sure what exactly you want to do, but Win32::Process is basically going to launch another application from your script. Here's what I did to launch a perl one-liner to test whether or not the connection attempt would hang.

sub RegConnect { my ($pObj, $ExitCode); my $comp = shift; my $pString = "perl -MWin32::TieRegistry -e " . '"' . '$Registry->Connect(' ."'" . $comp . "', 'LMachine');" . '"'; Win32::Process::Create($pObj, "c:\\perl\\bin\\perl.exe", $pString, 0, NORMAL_PRIORITY_CLASS, ".")|| die "Can't create Perl Process: $!\n"; $pObj->Wait(7000); $pObj->GetExitCode($ExitCode); if ($ExitCode) { $pObj->Kill(1); return 0; } return 1; }
Hope that's helpful,
Rich

Replies are listed 'Best First'.
(tye)Re: Using Win32::Process to prevent timeouts
by tye (Sage) on Feb 05, 2002 at 01:23 UTC

    Replacing the second argument with $^X will make this more portable (not to other operating systems, but to computers where Perl was installed to some place other than C:/Perl).

            - tye (but my friends call me "Tye")
      You know.. when I originally wrote this, I told myself to look up which variable held that data, knowing that I'd seen it before. Never got around to it.. good catch though.

      Rich

Re: Re: Using Win32::Process to prevent timeouts
by fullyloaded (Initiate) on Feb 05, 2002 at 06:15 UTC
    well all i need is a way to prevent my script from timing out, because when i add a delay in my script it times out after about 4 minutes, i want to avoid this if possible. im not sure if the win32::process does this, i just saw it in another script and i assume thats what it was doing, do u have a piece of code u use ro prevent ur scripts from timing out? thanks :)
      Ahh.. I see. Well your question is a tricky one because we really don't know any details about what you're doing. "timing out" could mean a lot of things, and there's a lot of variables that could effect things. The best bet is to start a new Seekers of Perl Wisdom node, posting what your problem is, and the offending script. Details will be very important if you'd like help that's benificial.

      Hope this helps,
      Rich

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://143343]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.