in reply to background Win32 process'

Check out Win32::Process, I think that's what you're looking for.

Replies are listed 'Best First'.
Re: Re: background Win32 process'
by sevensven (Pilgrim) on Oct 24, 2001 at 19:40 UTC

    You will need to use a flag that I dont see documented in Win32::Process, but that is in the first page of Process.pm (DETACHED_PROCESS).

    I hope the folowing code borrowed from Dave Roth's Win32 Perl Programming helps :

    use Win32::Process; # Win32::Process::Create( $process, $program, $command_line, $inherit, + $flags, $directory) $app = "d:\\apps\\perl\\bin\\perl.exe"; $cmd = 'perl daemon.pl'; $b_inherit = 1; $flags = CREATE_NEW_PROCESS || DETACHED_PROCESS; $dir = '.'; $result; $result = Win32::Process::Create( $process, $app, $cmd, $b_inherit, $flags, $dir); if ($result) { print "$cmd has been created with process id of $result\n"; } else { print "unable to start $cmd\n"; print "error : " . Win32::FormatMessage( Win32::GetLastError() ); }
Re: Re: background Win32 process'
by zuqif (Hermit) on Oct 24, 2001 at 19:43 UTC
    Thanks for clarifying sevensven .. and for the pointer blackmateria

    This needs some playing with ..

    the 'qif;
      Am I missing something here!?
      All I have now is the wrapper script waiting to end rather than the script it calls!?

      the 'qif;

        zuqif, the script I posted above is intended to launch another script in the background (daemon.pl in the example).

        So, you need to change whatever needs to be changed to match your system (my perl install dir is non orthodox)

        I tested the script before posting (even tryed to do a use strict, but it barfed some errors related to Win32 and I droped it, since this was just a code sample) and it worked as intended (by me, at least ;^)

        I'll put here the progie that I used as the background process, save it as daemon.pl in the same dir as the previous code and the try running the previous code and checking for the c:\daemon.log file

        use strict; my $log_file = 'c:\daemon.log'; open (LOG, ">$log_file") || die ("cant create $log_file : $!"); for ($i = 5 ; $i > 0 ; $i--) { print LOG "daemon running $i\n"; # print "daemon running $i \n"; sleep(1); } print LOG "thats all folks\n"; close LOG;
        The first script could even acept as parameters the name of the perl script it should run in the background,