Hi
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() );
$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.cgi
and
"debug=&dBinstance=eworkdb&startday=01&startmonth=07&startyear=2002&endmonth=08&endday=13&endyear=2002"
are tried to be
processed by perl.exe
I 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() );
$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 PATHEXT
The 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
