Write
a second program that runs as a daemon of sorts. Have it listen
to a socket or pipe and spawn/fork queries on behalf of the calling CGI
script. POE is excellent for this sort of thing and has modules included
for non-blocking SQL queries.
Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A
Kodak Company
email: [EMAIL PROTECTED]
www.encad.com
-----Original Message-----
From: Zac Morris (personal) [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 13, 2002 3:41 PM
To: [EMAIL PROTECTED]
Subject: HELP: Win32::Process not working within CGIHi all,I've tried everything I can think of, and have done web searching for two days. I need help! I'm trying to use Win32::Process to "fork" within a cgi application.Basically it's the old:CGI executes a long sql query (2-5 hours long) so I want to launch the cgi, display a nice "the report will be generated then emailed to you" message to the browser, then do the equivalent of closing STDOUT (stopping the user's browser from "chugging") then continue to run the script, process the SQL and email the report.This is really the equivalent of wanting to use Win32::Process to call the "same" .cgi application but with an ARGV representing all the original cgi's url encoded params so that the "parent" can die and close out the web app (iPlanet) session.I've tried something like:my $cgi_command = 'FeatureManagerReport.cgi "debug=' . $debug . '&dBinstance=' . $dBinstance;
$cgi_command .= '&startday=' . $startday . '&startmonth=' . $startmonth . '&startyear=' . $startyear;
$cgi_command .= '&endmonth=' . $endmonth . '&endday=' . $endday . '&endyear=' . $endyear;
$cgi_command .= '"';
Win32::Process::Create($ProcessObj,
"e:\\perl\\bin\\perl.exe",
$cgi_command,
1,
DETACHED_PROCESS,
"e:\\perl\\ework_perlscripts\\cgi-bin")|| print "ERROR:" . Win32::FormatMessage( Win32::GetLastError() );This returns no errors, but it also never generates the "final report". It would seem that the ARGV I'm trying to pass into the "FeatureManagerReport.cgi" just never makes it. In my mind this example would be the equivalant of:e:\perl\bin\perl.exe e:\perl\ework_perlscripts\cgi-bin\FeatureManagerReport.cgi "debug=&dBinstance=eworkdb&startday=01&startmonth=07&startyear=2002&endmonth=08&endday=13&endyear=2002"Which if I put into a command line fails because both the:e:\perl\ework_perlscripts\cgi-bin\FeatureManagerReport.cgiand"debug=&dBinstance=eworkdb&startday=01&startmonth=07&startyear=2002&endmonth=08&endday=13&endyear=2002"are tried to be processed by perl.exeI then tried:my $cgi_command = 'FeatureManagerReport.cgi "debug=' . $debug . '&dBinstance=' . $dBinstance;
$cgi_command .= '&startday=' . $startday . '&startmonth=' . $startmonth . '&startyear=' . $startyear;
$cgi_command .= '&endmonth=' . $endmonth . '&endday=' . $endday . '&endyear=' . $endyear;
$cgi_command .= '"';
Win32::Process::Create($ProcessObj,
"e:\\perl\\ework_perlscripts\\cgi-bin\\FeatureManagerReport.cgi",
$cgi_command,
1,
DETACHED_PROCESS,
".")|| print "ERROR:" . Win32::FormatMessage( Win32::GetLastError() );Which does trigger the "ERROR:" message to be printed (although nothing is returned from "Win32::FormatMessage( Win32::GetLastError() )" ) I even made sure that .cgi has a default file handler and that .cgi is even in my PATHEXTThe bulk of my problem is that the documentation for Win32::Process is HORRIBLE!!! I do a websearch "go Win32::Process perl" and get back several hundred entries which are all just various copies of the CPAN doc which is in atypical unix style geek speak with only one single example and no good "cookbook" style explanations, of what the individual parameters for Win32::Process actually do.Has ANYONE had a similar experience that can solve this problem or can offer me another "fork" alternative for win32?Thanks!!!-Zac Morris
