Welcome to WebmasterWorld Guest from 34.229.113.106

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

starting another perl script in background of Windows Web Appliaction

     
6:23 pm on Mar 5, 2007 (gmt 0)

New User

10+ Year Member

joined:Mar 5, 2007
posts:1
votes: 0


Hello!

I have a HTML/Perl Web application, and I need to start a Perl script to run in background, and then redirect users to another page right away without waiting until the script will finish its work.

I am running windows/IIS.

Thanks,
Alex

6:47 pm on Mar 9, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 19, 2005
posts:44
votes: 0


I haven't done exactly what you've requested, but here's how I've handled similar situations.

I setup my "background.pl" script in the scheduler to run every 5 minutes (or something like that). It looks in a predefined folder for files to act on. For example, let's say these files (named with the date/time) exist in the folder:


20070309-123500.txt
20070309-123623.txt
20070309-123648.txt

The "background.pl" script opens each one and does something based on the contents. As it finishes with each file, it deletes the file (or moves it to a "finished" directory).

If "background.pl" doesn't find any files, fine, it just exits.

Once that's working, then you just need to write your Perl CGI script so that its only job is to create these files in the specified folder. Therefore, it doesn't actually have to kick off the background process itself. It just creates the files, maybe based on form input, and provides its response to the user. And you will know that this submission will be handled within 5 minutes.

Naming the files with date and time helps to insure unique file names, though it won't work well if two submissions happen at the same time. Even better would be to use a counter. Or, Apache has an environment variable named UNIQUE_ID which is ideal for this; maybe IIS has something similar.