You can modify the Perl script, right? One thing you might try is to modify it so that it doesn't keep starting new Excels, but reuses the already running one. Win32::OLE->GetActiveObject("Excel.Application"); should take care of this. To create the excel object you would use something like this:

use Win32::OLE; use Win32::Semaphore; $excel = Win32::OLE->GetActiveObject("Excel.Application"); if (!$excel) { print "Not found, locking\n"; my $sem = Win32::Semaphore->new(1, 1, 'ASGdailyreport_StartExcel') +; $sem->wait(); print "locked, looking again\n"; $excel = Win32::OLE->GetActiveObject("Excel.Application"); if (!$excel) { print "still not found, starting\n"; $excel = Win32::OLE->new('Excel.Application') or die "oops\n"; # or # $excel = Win32::OLE->new('Excel.Application','Quit') or die +"oops\n"; # if you wish the Excel to quit once the last script using it +exits } $sem->release(); print "unlocked\n"; } if (!$excel) { die "Could not connect to or start MS Excel!\n"; } print "have an excel $excel\n";
I'm not sure though whether Excel handles two controling applications correctly, you would have to try that.

If it doesn't you might try to change the script into a service (see Win32::Daemon or Win32::Daemon::Simple) and control it either via Semaphores and a named pipe or by creating a file containing the parameters in a specific directory. The second might be easier to do from the ASP, you could create the file and redirect to a page that will check whether the report is ready (file appears in the finished reports directory) and either say something like "The report is being generated" and refresh in a few seconds or redirect to the report. Do I make sense?

Actually you might try if this tiny script doesn't solve the issue. It tries to connect to the running Excels and (if things work right) would close them if there is no other program referencing them. Not sure it would work, but it's worth a try:

use Win32::OLE; my $i = 0; while (1) { my $excel = Win32::OLE->GetActiveObject("Excel.Application"); last unless $excel; print "Found an excel\n"; last if ++$i > 10; print "Let's see ($i)\n"; }

Jenda
XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented.


In reply to Re^3: How to Get The Session id by Jenda
in thread How to Get The Session id by Nalina

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.