Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

XLSX tmp file error

by vishi83 (Pilgrim)
on Mar 02, 2012 at 11:00 UTC ( #957438=perlquestion: print w/replies, xml ) Need Help??
vishi83 has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks!!

I'm using Excel::Writer::XLSX (0.38 version) to write to xlsx files. But i seem to be getting the below error when i run my script as a CGI from the browser..

Couldn't open file /tmp/tdMZUai27q/xl/worksheets/sheet1.xml for writing.

However it is working fine if i run the script from command line. Internally the XLSX module uses File::Temp which i understand has issues with /tmp directories..
I'm using perl 5.8.7 on a HP-UX box.
I need some help to understand how to resolve this... Hope i dont to tweak the module itself to make it work..


Replies are listed 'Best First'.
Re: XLSX tmp file error
by jmcnamara (Monsignor) on Mar 02, 2012 at 20:15 UTC

    You can change the default temp dir that Excel::Writer::XLSX uses via the set_tempdir() method.


      Hi John,

      Glad to hear from you!
      I tried with 0.46 version of XLSX module.. But after setting the tmp dir in this way,
      I still see this error,
      Couldn't create sub directory /opt/apache/secure-htdocs/exceldir/CQ2RN +O0V36/xl/worksheets: Permission denied at /opt/perl-5.8.3/lib/site_pe +rl/5.8.3/Excel/Writer/XLSX/ line 809
      I've given 777 permissions to the exceldir folder with ownership belonging to the web user..
Re: XLSX tmp file error
by bitingduck (Chaplain) on Mar 02, 2012 at 15:29 UTC

    You should look in your error logs to see if it tells you why you can't open the file, but my first guess would be a permissions problem. When you do it from the command line you're doing it in a directory that you created, so you have read/write permission. When the browser is doing it through CGI it's running as another user (probably www or something similar) and for (hopefully obvious) security reasons the www user is limited in what directories it can read/write.

    Try creating either a subdirectory in your cgi directory, or one somewhere in below the DocumentRoot for the webserver, and make sure it has the permissions set so the server can write to it

Re: XLSX tmp file error
by Anonymous Monk on Mar 02, 2012 at 11:38 UTC

    What is the reason it Couldn't open file ... for writing ( hint, print value of $! variable )?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://957438]
Approved by Corion
and cookies bake in the oven...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-07-17 10:25 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (363 votes). Check out past polls.