jimjawn
August 11th, 2005, 09:24 PM
I've been looking around all over the place for an easy fix to this, but I'm stuck.
I need to write a perl script to recursively chown a directory. Here's my script:
#!/usr/bin/perl
open(PASSWD, "best");
while(<PASSWD>)
{
($uname, $passwd, $uid, $gid, $realname, $home, $shell)=
split(/:/);
# Change the permissions on the home directory
print "chowning $uid on $home...\n";
chown ($uname,$gid,$home");
# Change the permissions on the mailbox
print "chowning $uid on mailbox...\n";
chown ($uname, 12, "/var/spool/mail/$uname")
}
close PASSWD;
Now my question is how can I execute the first chown function recursively? I've also tried exec('/bin/chown -R $uid:$gid $home') but I can't seem to get it to work. Not sure where else to post this and I have an idea that this is a pretty simple fix. Hoping some perl nut can throw a fool a bone.
Thanks,
Jimjawn
I need to write a perl script to recursively chown a directory. Here's my script:
#!/usr/bin/perl
open(PASSWD, "best");
while(<PASSWD>)
{
($uname, $passwd, $uid, $gid, $realname, $home, $shell)=
split(/:/);
# Change the permissions on the home directory
print "chowning $uid on $home...\n";
chown ($uname,$gid,$home");
# Change the permissions on the mailbox
print "chowning $uid on mailbox...\n";
chown ($uname, 12, "/var/spool/mail/$uname")
}
close PASSWD;
Now my question is how can I execute the first chown function recursively? I've also tried exec('/bin/chown -R $uid:$gid $home') but I can't seem to get it to work. Not sure where else to post this and I have an idea that this is a pretty simple fix. Hoping some perl nut can throw a fool a bone.
Thanks,
Jimjawn