Pad wrote:
In my script, I am trying to use find cmd (Solaris 8 OS) to change
the permission and ownership of a file. I don't know how to get it
working as I get 'find incomplete statement'.
To make things simpler, here is a small modified snippet of my code..
#!/bin/perl
use warnings;
my $tagname="XYZ";
my $user="orauser";
my $seq=01;
system( "echo find /${tagname}_$seq/oradata/$tagname -user 29334 -
exec chown $user {} \\\; ");
output:
find /XYZ_01/oradata/XYZ -user 29334 -exec chown orauser {} ;
What I really wanted is:
find /XYZ_01/oradata/XYZ -user 29334 -exec chown orauser {} \;
(please notice '\' just before semi-colon).
I used 'echo' statement just to show you what is the problem. In
reality, I wanted to use find cmd to change the permission say,
system( " find /${tagname}_$seq/oradata/$tagname -user 29334 -exec
chown $user {} \\\; ");
Please let me know why the escape character does n't work for me? Any
help to resolve the problem is much appreciated.
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__
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/