Windows Background Process
Hello, I need to start an external program from my perl script. This program will need to run in the background so my script can continue doing other things. It also still needs to notify the program when it terminates. I would appreciate any help on how I would do this. My environment is Windows NT 4.0, with Activestate perl 5.6.1. I'm also not sure how Windows runs a background process, so any tips there would be appreciated. Lastly, I've been monitoring this list for a few weeks now. It has been extremely helpful in getting me started with Perl. Thank you to everyone involved. Tina Ouellette __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
Re: Windows Background Process
> I need to start an external program from my perl > script. This program will need to run in the > background so my script can continue doing other > things. It also still needs to notify the program > when it terminates. > > I would appreciate any help on how I would do this. > My environment is Windows NT 4.0, with Activestate > perl 5.6.1. I'm also not sure how Windows runs a > background process, so any tips there would be > appreciated. No one else has attempted to answer this (too busy having fun out obfuscating each other ;>), so even though I'm not well qualified to answer, I'll have a go. Basically, afaik, windows doesn't have a native way of doing this at the OS level, at least afaik. But all is not lost; read on. On unix like OSes, the main piece relevant to this is called a 'fork'. In a nutshell, a given process has a child, resulting in the original process (parent) and the child. Perl has a high level function, also called 'fork', that makes use of this. It uses native forking capabilities on unix like OSes, and emulations on some other OSes, and simply isn't available on yet other OSes. With perl 5.6, on some versions of Windows, a fork emulation has been written. It is likely to be quite slow, but it may well be usable. So, try that. For more info: perldoc -f fork Apparently, a module called Win32::Process is also available for this sort of thing and may be a lot faster. hth.
RE: Windows Background Process
I have this snippet of code that I picked up from "Learning Perl on Win32 Systems" (O'Reilly) that may be helpful. For more info, check the Win32::Process module. As a Perl rookie myself, I really can't explain it - I just know it works. ;-) use Win32::Process; Win32::Process::Create($Process, "c:\\program files\\ultraedit\\uedit32.exe", "uedit32 $alljobs_list" , 0, DETACHED_PROCESS, ".")|| die "Creating UltraEdit process: $!"; Dan Murphy [EMAIL PROTECTED] EMC Corp.508-435-1000 x14559 Hopkinton, MA 01748 EMC2 where information lives -Original Message- From: C.Ouellette [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 6:17 AM To: [EMAIL PROTECTED] Subject: Windows Background Process Hello, I need to start an external program from my perl script. This program will need to run in the background so my script can continue doing other things. It also still needs to notify the program when it terminates. I would appreciate any help on how I would do this. My environment is Windows NT 4.0, with Activestate perl 5.6.1. I'm also not sure how Windows runs a background process, so any tips there would be appreciated. Lastly, I've been monitoring this list for a few weeks now. It has been extremely helpful in getting me started with Perl. Thank you to everyone involved. Tina Ouellette __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
RE: Windows Background Process
I've tried what you are talking about. Specifically I wanted to run a Perl program from NT Task Scheduler in the background. The mentioned Win32::Process works (http://www.xav.com/perl/site/lib/Win32/Process.html) but... if you are trying to do it through Scheduler who'll always have at least one window pop up(for MSTask.exe). If someone knows something different please pass it on. This window is very annoying 8^) Here's a practice script to chew on (stolen from someone else): #!c:\perl\perl.exe -w use Win32::Process; use Win32; my $ProcessObj; my $notepath = 'C:\winnt\system32\notepad.exe'; use strict; Win32::Process::Create($ProcessObj, $notepath, "notepad", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Suspend(); $ProcessObj->Resume(); $ProcessObj->Wait(INFINITE); sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } JS -Original Message- From: murphy, daniel (BMC Eng) [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 28, 2001 1:59 PM To: '[EMAIL PROTECTED]' Subject: RE: Windows Background Process I have this snippet of code that I picked up from "Learning Perl on Win32 Systems" (O'Reilly) that may be helpful. For more info, check the Win32::Process module. As a Perl rookie myself, I really can't explain it - I just know it works. ;-) use Win32::Process; Win32::Process::Create($Process, "c:\\program files\\ultraedit\\uedit32.exe", "uedit32 $alljobs_list" , 0, DETACHED_PROCESS, ".")|| die "Creating UltraEdit process: $!"; Dan Murphy [EMAIL PROTECTED] EMC Corp.508-435-1000 x14559 Hopkinton, MA 01748 EMC2 where information lives -Original Message- From: C.Ouellette [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 6:17 AM To: [EMAIL PROTECTED] Subject: Windows Background Process Hello, I need to start an external program from my perl script. This program will need to run in the background so my script can continue doing other things. It also still needs to notify the program when it terminates. I would appreciate any help on how I would do this. My environment is Windows NT 4.0, with Activestate perl 5.6.1. I'm also not sure how Windows runs a background process, so any tips there would be appreciated. Lastly, I've been monitoring this list for a few weeks now. It has been extremely helpful in getting me started with Perl. Thank you to everyone involved. Tina Ouellette __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/