chmod directories recursively

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fabian Steiner

    chmod directories recursively

    Hello!

    As far as I can see os.chmod() doesn't adjust permissions on directories
    recusively. Is there any other possibility to achieve this aim except for
    calling os.system('chmo d -R /dir') directly?

    Thanks,
    Fabian
  • Jennifer Thacher

    #2
    Re: chmod directories recursively

    Fabian Steiner wrote:
    Hello!
    >
    As far as I can see os.chmod() doesn't adjust permissions on directories
    recusively. Is there any other possibility to achieve this aim except for
    calling os.system('chmo d -R /dir') directly?
    >
    Thanks,
    Fabian
    Check out os.path.walk.

    James

    Comment

    • Fabian Steiner

      #3
      Re: chmod directories recursively

      Jennifer Thacher wrote:
      Fabian Steiner wrote:
      >As far as I can see os.chmod() doesn't adjust permissions on directories
      >recusively. Is there any other possibility to achieve this aim except for
      >calling os.system('chmo d -R /dir') directly?
      >>
      >Thanks,
      >Fabian
      >
      Check out os.path.walk.
      Thanks for your advice. This pointed me into the right direction.
      For those who are interested the function passed to os.path.walk looks like
      this:

      def _chownRecursive (arg, dirname, fnames):
      os.chown(dirnam e, arg[0], arg[1])
      for file in fnames:
      os.chown(os.pat h.join(dirname, file), arg[0], arg[1])


      Fabian

      Comment

      Working...