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

Hi Monks,

I am developing a intranet web report using cgi script to work in windows 2000 environment and IIS 5.0. I want to perform the following activities:

1. Copy an excel template to my working location and name it to todays date.

2. Collect details from a database.

3. Write database query details to an excel File.

4. Generate an HTML file with other details.

5. Embed the HTML file with the body of the Mail and attach the Excel file

All these steps works well when I execute the script in the command line prompt. But, when I execute them in the web all the steps except step 2 fails.

On clicking the link the report either hangs or displays cannot copy the excel file.

The modules used and the functions I have used is show below:

use DBI; use IniConf; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use File::Copy qw(copy); use MIME::Lite; #FOR EXCEL COPY sub CheckDrive(){ if ( ! opendir(TEMPLATEPATH,$GIST_TEMPLATEPATH)) { my $objnet=Win32::OLE->CreateObject("Wscript.Network"); $objnet->MapNetworkDrive("H:","\\\\prodapt-bpo\\bpodata"); } copy("$GIST_TEMPLATEPATH"."$GIST_EXCELNAME","$ExcelName") or die D +isplayError("Copy failed: $ExcelName : $!"); closedir(TEMPLATEPATH); } #TO UPDATE THE EXCEL sub UpdateExcel(){ my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); #Win32:: +OLE->GetActiveObject('Excel.Application') my $Book = $Excel->Workbooks->Open( {FileName => $ExcelName} ); my $GistSheet = $Book->Worksheets("$GIST_ESHEETNAME"); my $AutoGistUptoThisMonth = shift; foreach my $row (5..19) { $col = 14; $GistSheet->Cells($row,$col)->{'Value'}= $AutoGistUptoThisMont +h->{$row}; } foreach my $row (5..19) { $col = 15; $GistSheet->Cells($row,$col)->{'Value'}= $AutoGistExcel{$row}; } $Book->Save; $Book->Close; } #TO SEND MAIL sub SendEmail(){ $msg = MIME::Lite->new( From =>$GIST_MAIL_FROM, To =>$GIST_MAIL_TO, CC =>$GIST_MAIL_CC, Subject =>$GIST_MAIL_SUBJECT.$MailDate, Type =>'text/html', Data => $MailContent ); $msg->attach( Type => 'application/vnd.ms-excel', Path => $ExcelName, Disposition => 'attachment' ); $msg->send('smtp',"mail.prodapt.com"); }

Request your help to resolve this issue. Thanks pdl_babu

Replies are listed 'Best First'.
Re: Perl and windows 2000
by marto (Cardinal) on Feb 09, 2006 at 14:21 UTC
    Hi pdl_babu,

    have you checked the permissions for the IUSR_yourservernamehere account (it needs the proper permissions to write to the directoy) and that under the IIS administraton utility you have permissions set to allow write access to the directory in question?
    Let us know if this helps you at all.

    Cheers

    Martin

      Hi Marto,

      I check the permission for the IUSR_SERVER account and it is under the restricted user group permission (can read and save documents).

      Also as I said earlier, the script does all the required things when I run it in the command prompt.

      Pls. throw your thoughts on this.

      Thanks-pdlbabu

        pdl_babu,

        'Also as I said earlier, the script does all the required things when I run it in the command prompt.'

        When you run it from the command prompt you are not logged into the server as the IUSR account. The account you are logged on as will (Im sure) have more permissions than the IUSR account. Did you check the IIS settings? Have you read any of the documentation for IIS 5.0?

        Martin
Re: Perl and windows 2000
by beachbum (Beadle) on Feb 09, 2006 at 18:22 UTC

    Sounds like you are on the right track already... Just check to make sure that your web user (make sure you select the right one) has rights on the file system and folders that you are using to create/modify files.

    Also, if these are mapped drives, they won't be available to the iis user.. even administrator.