Recursive chmod/chown

Discussion in 'Perl Misc' started by Christopher W Aiken, Feb 3, 2006.

  1. In UNIX a simple "-R" option on the "chmod/chgrp/chown" command
    will traverse all files and directories. Is there a simple way of
    doing this same thing is a Perl script?

    -=[cwa]=-
    Christopher W Aiken, Feb 3, 2006
    #1
    1. Advertising

  2. Christopher W Aiken

    Paul Lalli Guest

    Christopher W Aiken wrote:
    > In UNIX a simple "-R" option on the "chmod/chgrp/chown" command
    > will traverse all files and directories. Is there a simple way of
    > doing this same thing is a Perl script?


    Not quite as simple, no, but still relatively painless:

    use File::Find;
    find ( sub { chmod 0755, $_ or warn "Cannot chmod $File::Find::name:
    $!"; }, '.');

    Read more about File::Find at:
    perldoc File::Find

    Paul Lalli
    Paul Lalli, Feb 3, 2006
    #2
    1. Advertising

  3. Christopher W Aiken

    Ian Wilson Guest

    Christopher W Aiken wrote:
    > In UNIX a simple "-R" option on the "chmod/chgrp/chown" command
    > will traverse all files and directories. Is there a simple way of
    > doing this same thing is a Perl script?
    >


    File::Find ?
    Ian Wilson, Feb 3, 2006
    #3
  4. On 3 Feb 2006 08:02:57 -0800, "Paul Lalli" <> wrote:

    >Christopher W Aiken wrote:
    >> In UNIX a simple "-R" option on the "chmod/chgrp/chown" command
    >> will traverse all files and directories. Is there a simple way of
    >> doing this same thing is a Perl script?

    >
    >Not quite as simple, no, but still relatively painless:
    >
    >use File::Find;
    >find ( sub { chmod 0755, $_ or warn "Cannot chmod $File::Find::name:
    >$!"; }, '.');
    >
    >Read more about File::Find at:
    >perldoc File::Find
    >
    >Paul Lalli



    Thanks !!! Doesn't look too bad to code.

    -=[cwa]=-
    Christopher W Aiken, Feb 3, 2006
    #4
  5. Paul Lalli wrote:
    > Christopher W Aiken wrote:
    >>In UNIX a simple "-R" option on the "chmod/chgrp/chown" command
    >>will traverse all files and directories. Is there a simple way of
    >>doing this same thing is a Perl script?

    >
    > Not quite as simple, no, but still relatively painless:
    >
    > use File::Find;
    > find ( sub { chmod 0755, $_ or warn "Cannot chmod $File::Find::name:
    > $!"; }, '.');
    >
    > Read more about File::Find at:
    > perldoc File::Find


    Alternatively you can make use of the UNIX feature:

    system "chmod -R 0755 $dir"

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Feb 3, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GfxGuy

    JNI/Linux/chown

    GfxGuy, May 28, 2005, in forum: Java
    Replies:
    6
    Views:
    2,519
    Ross Bamford
    May 29, 2005
  2. James Colannino

    os.chown()

    James Colannino, Nov 11, 2005, in forum: Python
    Replies:
    3
    Views:
    9,378
    Tim Roberts
    Nov 13, 2005
  3. Carsten Haese

    Re: chown'ing by script

    Carsten Haese, Jan 6, 2010, in forum: Python
    Replies:
    4
    Views:
    289
    Steve Holden
    Jan 6, 2010
  4. Brian Candler
    Replies:
    2
    Views:
    330
    Emiel van de Laar
    Mar 2, 2005
  5. superfly2

    chown and file ownership

    superfly2, Jul 21, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    131
    J├╝rgen Exner
    Jul 22, 2004
Loading...

Share This Page