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

Hi, I'm new here so please be gentle. I've got a script running a permanent loop which runs another script which shadows two filesystems on different NT boxes using FTP. How can I tell which Perl scripts are running on the box. The process list only shows that an instance of Perl.exe is running for each script, and there are other Perl applications on the box. Basically I just want to see if my script is running and restart it if it isn't. Thanks in advance. Knot
  • Comment on How can I tell which perl scripts are running on NT?

Replies are listed 'Best First'.
Re: How can I tell which perl scripts are running on NT?
by thunders (Priest) on Jun 21, 2002 at 18:29 UTC
    This is a good article on this subject. This is the more simple solution using the instsrv and srvany applications to register and run a script as a named service(you can control them with the net command). Dave Roth explains this in better detail in his excellent book:Win32 Perl Scripting. In the same chapter (Chapter 8: Win32 Services) he dives into his module Win32::Daemon which appears to be a more powerful and robust way to write services.
Re: How can I tell which perl scripts are running on NT?
by perrin (Chancellor) on Jun 21, 2002 at 17:22 UTC
    Incidentally, using cron or the Windows equivalent "Scheduled Tasks" is usually a better way to go than a script that runs forever.
      I'm in full agreement.

      I wouldn't be running a forever loop. It's much more efficient to run a perl script in crontab or scheduled tasks than it is to run it as a daemon.

      Just my 2 cents.

      --Robo

Re: How can I tell which perl scripts are running on NT?
by Marza (Vicar) on Jun 21, 2002 at 16:36 UTC

    Ack! a forever loop???. Did you look into converting the script to a service? Take a look at perlapp from active state, it will take your script and make it an executable. There are others that do this but I can't think of their names at the moment. Not had my coffee yet! ;)

    But as to your question. Since Perl is interpreted you see the Perl Binary listed as it is running your script.

    Edit:Now that I have had my coffee. Perrin is correct. A scheduled task is a better approach as it will not put the cycles on the cpu as a forever loop does.
Re: How can I tell which perl scripts are running on NT?
by Galen (Beadle) on Jun 24, 2002 at 14:37 UTC
    I agree with the other comments in this thread regarding running a permanent loop. However, I assume there is a chance you don't have the time right now to change your setup. A very simple way (and a complete hack) of telling which of your scripts are running would be to *copy* the perl executable (c:\perl\bin\perl.exe) to another filename (c:\perl\bin\foo.exe), and then exec it using foo.exe. Then, when you check processes you'll see one script running as foo.exe and another running as perl. This is rather untidy, but simple to do in less than a minute.