Pad wrote:

On Feb 8, 6:24 am, [EMAIL PROTECTED] (John W. Krahn) wrote:

This may work better (UNTESTED):

#!/bin/perl
use warnings;
use strict;

use File::Find;

my $tagname = 'XYZ';
my $user    = getpwnam 'orauser';
my $seq     = '01';

find sub {
     my ( $uid, $gid ) = ( lstat )[ 4, 5 ];
     return if $uid != 29334;
     # If 29334 is the user *name* and not the UID
     # then do this instead:
     #return if getpwuid( $uid ) ne '29334';
     chown $user, $gid, $_
         or warn "Cannot change owner of file '$File::Find::name' $!";
     }, "/${tagname}_$seq/oradata/$tagname";

__END__

Thank you so much.. That was helpful.  I feel it looks more  perl like
solution than calling unix OS cmd.

Can you pl.help  me how to get chmod cmd  that I am trying to set  run
on those directories. I was thinking of using  system (" find ... -
exec chmod  755 {} \; ")

find sub {
    my ( $uid, $gid ) = ( lstat )[ 4, 5 ];
    return if $uid != 29334;
    # If 29334 is the user *name* and not the UID
    # then do this instead:
    #return if getpwuid( $uid ) ne '29334';
    chown $user, $gid, $_
        or warn "Cannot change owner of file '$File::Find::name' $!";
    chmod 0755 $_
        or warn "Cannot change permissions of file '$File::Find::name' $!";
    }, "/${tagname}_$seq/oradata/$tagname";


perldoc perlfunc
[ SNIP ]
    Functions for filehandles, files, or directories
        "-X", "chdir", "chmod", "chown", "chroot", "fcntl", "glob",
        "ioctl", "link", "lstat", "mkdir", "open", "opendir",
        "readlink", "rename", "rmdir", "stat", "symlink", "sysopen",
        "umask", "unlink", "utime"


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to