Enlightened ones:

The zip command string below works as expected from the commandline on both Solaris and Mac OS X: the paths are excluded and I get a zip file containing only the files matching *.$fileext. But when I run the same command via Perl system() in a CGI script, the zip file contains empty directories for the full path from host root down to htdocs, with the files in the last directory.

Both the commandline and system() cases send the expected STDOUT to the file $joblog, and nothing shows up in the file $joberrors.

This command line excludes directories as advertised in man zip:

# /usr/bin/zip -D $zipfile $somepath/*.$fileext 1>$joblog 2>$joberrors

This system call does not:

$zipcommand = "/usr/bin/zip -D $zipfile $somepath/*.$fileext 1>$joblog + 2>$joberrors"; system("$zipcommand");

I noticed a similar question with tar on stackoverflow.com: How do i make a “system call to tar files(along with exclude tag)” to work in Perl.

Is there something about passing commandline switches that I am missing?


In reply to Why doesn't system("zip -D") exclude directories? by YuTsun

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.