Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

background Win32 process'

by zuqif (Hermit)
on Oct 24, 2001 at 18:49 UTC ( [id://121128]=perlquestion: print w/replies, xml ) Need Help??

zuqif has asked for the wisdom of the Perl Monks concerning the following question:

Greets to all the Monks out there.
I normally work 90% of perl code on RH 'nix, but thanks to SuperSearch,
have recently been working various use Win32 scripts, w/ActiveState on '98SE.
My question is this : Is it possible to run a perl script in the background!?

Possible W'doze solution, or perl?

I did wonder about wrapping the script in another, with a system call or somesuch ..
Any and all comments, humbly received!
the 'qif;

Replies are listed 'Best First'.
(tye)Re: background Win32 process'
by tye (Sage) on Oct 24, 2001 at 23:07 UTC

    system(1,$command) is the simplest way. I'm a bit disappointed that this isn't supported on Unix because then it would also be the most portable... but then, I should just "fix" that...

            - tye (but my friends call me "Tye")
Re: background Win32 process'
by blackmateria (Chaplain) on Oct 24, 2001 at 19:01 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() ); }
      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;
Re: background Win32 process'
by zuqif (Hermit) on Oct 25, 2001 at 02:30 UTC
    Not wanting to appear ungrateful for all your efforts -
    many thanks to all who've contributed!
    But I thot that was the question I asked:
    I need the ability to run a script in the background, under Windows98.
    The links above all relate to WinNT/2000
    (altho have yet to install / try Win32::Daemon - thx Tye)
    The system(1,$cmd); option makes no difference under 98

    I hope am not being dumb here ..
    local mcp SysAdm is doubtful that its even poss :(
    the 'qif;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 09:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found