http://www.perlmonks.org?node_id=505669


in reply to Re^4: Archive::Zip errors
in thread Archive::Zip errors

It sounds like I have my permissions set wrong and that perhaps archive::zip is less forgiving than apache. I'll try opening my permissions and owner to something totally public all along that path and see what happens.

Well, you're getting *very* close. Archive::Zip has nothing to do with permissions directly. I'm almost postive that what you're missing is that apache runs on one user account, that quite likely has slightly different permissions than your login user account.

When you execute a CGI manually, you're running as *you*. Meanwhile, when one is called via the Apache daemon, it's running as (apache|httpd|etc.).

Replies are listed 'Best First'.
Re^6: Archive::Zip errors
by fluffyvoidwarrior (Monk) on Nov 04, 2005 at 16:55 UTC
    The apache daemon will write to these directories in response to events from remote users interaction via cgi. When the same remote connection to the same cgi script invokes archive::zip it wiill not write a file. This code will write to disk:
    open(WOBBLE, ">/caralan_com/system/proofing/cam_proofs/steve/live/fl +unk2.txt"); my $zip = Archive::Zip->new(); $zip->addTree( '/delme/wibble', 'customer_uploads' ); $zip_return_code = $zip->writeToFileHandle('WOBBLE'); close(WOBBLE);
    But this will not:
    my $zip = Archive::Zip->new(); $zip->addTree( '/delme/wibble', 'customer_uploads' ); $zip_return_code = $zip->writeToFileNamed('/delme/$proofstem.zip');

      You're allocating two different files, but both are ultimately being written to by Archive::Zip. So, again: You have a permissions problem. I don't see any problem whatsoever with the module at this point.

      To debug this, both snippets should try to write to the same filename in the same directory. If you can do that and *still* have one work and one not, then we have somthing interesting...

      Update:

      In case you're confused, it looks like the first snippet is writing to "/caralan_com/system/proofing/cam_proofs/steve/live/flunk2.txt".

      The second is writing to "/delme/$proofstem.zip"