I have been working on a problem and I am looking for some insight. I am using perl to check File Permissions on a UNIX Filesystem using stat, however I need to determine if a file is '0755' or less permissive such as '0644'. Thus if I have a file that is either 0750, 0751, 0754, or 0755, my check would succeed, but 0756, 0757, or 0752 (since the write bit is on for those conditions) which would fail. (This has to be done for user, group and world permissions, which makes it more complicated). My other problem was that I could not install any modules since the script will reside of numerous UNIX boxes. My thought has been to convert each digit to a binary number and do a series of comparsions, as strings, such as comparing the binary number of 5: (101) to 4: (100) which should succeed. I thought about binary comparisons, however that doesn't seem to get me the information that I need (ie XOR, AND, etc). If anyone has some insight to my problem, it would be greatly appreciated.


In reply to UNIX File Permissions equal or less than conditions by Themis74

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.