[Chicago-talk] chown inside a script
Brian Katzung
briank at kappacs.com
Thu Dec 6 16:41:04 PST 2007
Jay,
Here's a rough code snippet to get you started.
use File::Find;
# Queue looks like /some/path/closed/user_name/file_name
my $base_dir = '/some/path/closed';
sub proc_files
{
return unless (-f $File::Find::name &&
$File::Find::name =~ m{^\Q$base_dir\E/([^/]+)/([^/]+)$});
my ($user, $file) = ($1, $2);
print "Process file $file in queue for user $user\n";
}
find({ 'wanted' => \&proc_files, 'follow' => 0, 'no_chdir' => 1 },
$basedir);
- Brian
Jay Strauss wrote:
> On Dec 6, 2007 3:57 PM, Brian Katzung <briank at kappacs.com> wrote:
>> Jay et al,
>>
>> I'm not sure about the "easier" part, but I would probably do something
>> like this:
>>
>> - Create a queue directory for each employee, e.g.
>> /some/path/closed/{emp1,emp2,emp3}
>> with access by managers (you)
>>
>> - When you "close" the employees' files in your app, save them to the
>> appropriate employee queue
>>
>> - Have a root script monitor the queue tree (you could use "fam" (file
>> alteration monitor) API or roll your own)
>>
>> - When plain files appear in the employee queues, the root script would
>> move them to some standardized place (e.g. to ~emp/my_app_closed_files/)
>> with appropriate checks for file (directory) types, name collisions,
>> etc. and chown them.
>>
>> - Brian
>
> The queue part seems hard, but I'll look into the "fam" API and maybe
> have a root script do the chown without the cgi.
>
> Thanks
> Jay
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
>
--
Brian Katzung, Kappa Computer Solutions, LLC
Leveraging UNIX, GNU/Linux, open source, and custom
software solutions for business and beyond
Phone: 877.367.8837 x1 http://www.kappacs.com
More information about the Chicago-talk
mailing list