Running a perl script in the background on Windows(95/NT) 
Author Message
 Running a perl script in the background on Windows(95/NT)

Please forgive me if this is the wrong newsgroup.  My newserver doesn't
carry comp.lang.perl (but it carries c.l.p.misc...).

I've written a perl script on a Windows95/NT system that I would like to
run and have sit in the background.  The script itself does a bit of
processing, then sleeps for 5 minutes, over and over again.

I come from a UNIX background where this sort of thing is trivial but I
can't figure out how to do it in Windows.  Right now, when the script
starts, it seems to run through a DOS window.  As long as the script is
running the DOS window is on the screen (or minimized and on the taskbar).
If I kill the DOS window the process quits.  I'd like to set up the script
so that it doesn't use the DOS window.  I don't want it to show up on the
taskbar.

From looking at the task manager I see that Windows95/NT recognizes a
difference between applications and processes.  It seems that applications
have an associated window and processes don't.  So I guess I want to
convert my perl script from an application to a process.

How can I do this?

Thanks.

_M_



Sun, 25 Jun 2000 03:00:00 GMT  
 Running a perl script in the background on Windows(95/NT)

Quote:

>Please forgive me if this is the wrong newsgroup.  My newserver doesn't
>carry comp.lang.perl (but it carries c.l.p.misc...).

>I've written a perl script on a Windows95/NT system that I would like to
>run and have sit in the background.  The script itself does a bit of
>processing, then sleeps for 5 minutes, over and over again.

>I come from a UNIX background where this sort of thing is trivial but I
>can't figure out how to do it in Windows.  Right now, when the script
>starts, it seems to run through a DOS window.  As long as the script is
>running the DOS window is on the screen (or minimized and on the taskbar).
>If I kill the DOS window the process quits.  I'd like to set up the script
>so that it doesn't use the DOS window.  I don't want it to show up on the
>taskbar.

>From looking at the task manager I see that Windows95/NT recognizes a
>difference between applications and processes.  It seems that applications
>have an associated window and processes don't.  So I guess I want to
>convert my perl script from an application to a process.

>How can I do this?

>Thanks.

>_M_


Try the SRVANY utility supplied in the WinNT Resource Kit, available from
the microsoft site.

You would use this to act as a stub for your perl script, effectivley
creating yourself an .pl NT service process.

Does not work on 95 (that I know of) as 95 uses a different mechanism to
achieve the same goal.

If I have time to dig the bits out, I'll mail them to you....

Regards
AndyS



Sun, 25 Jun 2000 03:00:00 GMT  
 Running a perl script in the background on Windows(95/NT)

Quote:

> I've written a perl script on a Windows95/NT system that I would like to
> run and have sit in the background.  The script itself does a bit of
> processing, then sleeps for 5 minutes, over and over again.

> I come from a UNIX background where this sort of thing is trivial but I
> can't figure out how to do it in Windows.  Right now, when the script
> starts, it seems to run through a DOS window.  As long as the script is
> running the DOS window is on the screen (or minimized and on the taskbar).
> If I kill the DOS window the process quits.  I'd like to set up the script
> so that it doesn't use the DOS window.  I don't want it to show up on the
> taskbar.

Does NT's 'start' command do what you need? I don't know about 95, though.

-----------------------------
   Mark S. Reibert, Ph.D.

  Mystech Associates, Inc.
  3233 East Brookwood Court
   Phoenix, Arizona 85044

    Tel: (602) 732-3752
    Fax: (602) 706-5120

-----------------------------



Sun, 25 Jun 2000 03:00:00 GMT  
 Running a perl script in the background on Windows(95/NT)

I use the Task Scheduler on Win95 (the noew onw that is part of the IE4.0
upgrade) and run a .bat file as a minimized icon. On my 266PII you barely
notice that a Perl script is running except for the appearance of a DOS icon
on the task bar. My application runs for about 5 minutes and is both disk
and resource intensive (including using the WININET.DLL for Internet
access). The only issue I have with the Task Scheduler is that it can't tell
if my Perl script exits abnormally (that is hidden by the batch file). I use
a 'panic' file and a .log file to record process events to get round this.

Regards
James :-)
============================================
James Ringrose
Boston MA
============================================

Quote:

>Please forgive me if this is the wrong newsgroup.  My newserver doesn't
>carry comp.lang.perl (but it carries c.l.p.misc...).

>I've written a perl script on a Windows95/NT system that I would like to
>run and have sit in the background.  The script itself does a bit of
>processing, then sleeps for 5 minutes, over and over again.

>I come from a UNIX background where this sort of thing is trivial but I
>can't figure out how to do it in Windows.  Right now, when the script
>starts, it seems to run through a DOS window.  As long as the script is
>running the DOS window is on the screen (or minimized and on the taskbar).
>If I kill the DOS window the process quits.  I'd like to set up the script
>so that it doesn't use the DOS window.  I don't want it to show up on the
>taskbar.

>From looking at the task manager I see that Windows95/NT recognizes a
>difference between applications and processes.  It seems that applications
>have an associated window and processes don't.  So I guess I want to
>convert my perl script from an application to a process.

>How can I do this?

>Thanks.

>_M_




Sun, 25 Jun 2000 03:00:00 GMT  
 Running a perl script in the background on Windows(95/NT)

Quote:

> Please forgive me if this is the wrong newsgroup.  My newserver doesn't
> carry comp.lang.perl (but it carries c.l.p.misc...).

> I've written a perl script on a Windows95/NT system that I would like to
> run and have sit in the background.  The script itself does a bit of
> processing, then sleeps for 5 minutes, over and over again.

> I come from a UNIX background where this sort of thing is trivial but I
> can't figure out how to do it in Windows.  Right now, when the script
> starts, it seems to run through a DOS window.  As long as the script is
> running the DOS window is on the screen (or minimized and on the taskbar).
> If I kill the DOS window the process quits.  I'd like to set up the script
> so that it doesn't use the DOS window.  I don't want it to show up on the
> taskbar.

> From looking at the task manager I see that Windows95/NT recognizes a
> difference between applications and processes.  It seems that applications
> have an associated window and processes don't.  So I guess I want to
> convert my perl script from an application to a process.

> How can I do this?

> Thanks.

> _M_


Use Win32::Process and launch your perl script as a detached process.
This works beautifully and the script won't show up on the task bar.
use Win32;
use Win32::Process;

#Create the process object.
Win32::Process::Create($ProcessObj,
    "C:\\PERL5\\BIN\\PERL.EXE",
    "perl f:\\scripts\\myscript.pl",
    0, # Don't inherit.
    DETACHED_PROCESS,
    ".") ||  # current dir.
    die &print_error;

sub print_error {
    print Win32::FormatMessage( Win32::GetLastError() );

Quote:
}

Regards,
deflores


Mon, 26 Jun 2000 03:00:00 GMT  
 Running a perl script in the background on Windows(95/NT)


Quote:
> My newserver doesn't
> carry comp.lang.perl (but it carries c.l.p.misc...).

That's the right thing to do; c.l.p is defunct. c.l.p.misc is the proper
home for most Perl questions which aren't answered in the docs. Have fun
with Perl!

--
Tom Phoenix           http://www.teleport.com/~rootbeer/

Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



Mon, 26 Jun 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Perl on Apache 1.3.3 running on Windows 95/NT

2. Running a VT100 perl script in Windows 95

3. Test running PERL script in Windows 95

4. Running a perl script on Windows 95

5. make ftp on perl script with windows 95/NT

6. Where can I get Perl for Windows NT or Windows 95

7. Running Perl in the Windows/NT background ??

8. Running Perl in the Windows/NT background ??

9. Relational database for Windows/Windows 95/NT

10. How to run perl in Windows 95?

11. Eat my dust - Perl running on Windows 95

12. Problem running system commands from Win32 perl under Windows 95

 

 
Powered by phpBB® Forum Software