Working on an old Darwin 8.1 box where there have been layers of ACLs applied. The only native tools supplied to work with the ACLs are extended versions of ls and chmod.

We need to move off this box so to help I'm creating a script that produces an ACL map for a given user.

To my delight I've found that the file and directory names contain lots of interesting characters I have to be able to handle.

So far this works but I'm concerned that it blows up if I encounter anything with a " character in the name.

I've been searching for a better way but I need hints.

#!/usr/bin/perl -w # trying to map acls use Getopt::Long; use File::Find; no warnings 'File::Find'; my $optuser = ''; my $findroot = ''; GetOptions('user:s' => \$optuser, 'root=s' => \$findroot); unless( $findroot ){ print<<HERE $0 --root path [--user username] perform a recursive find rooted at the given pathname producing an +ACL map. if optional username is provided, filter ACL map results to that us +ername. HERE } find(\&wanted, $findroot); sub wanted { -f && next; open RES, "ls -lde \"$_\" |"; # filespec is discarded <RES>; while (my $acl=<RES>){ if($optuser){ $acl =~ /user:$optuser\s/ && print "$File::Find::name $acl"; } else { print "$File::Find::name $acl"; } } }

I'm interested in the 3 arg version of open() but so far I've been unable to get it working for this task; the spaces and shell chars are passed to ls and it seems I'm back to square one.

open RES, "-|", "ls -lde $_";

In reply to Shell characters coming back to bite me. by mull

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.