in reply to Perms Perms Perms
how the hell can I pass @ARGV values to the perms add command as constants?
the question you should be asking is: how can i convert @ARGV values to constants for use with the add command?
i haven't tested this, but it *looks* right...
Update: looks likeBrowserUK beat me to it. well, at least i've given you a start on taking variable params from the command-line...#!/usr/bin/perl require 5.006; use strict; use warnings; $|++; use Win32::Perms; ## takes directory path and permissions as args my( $path, @requested_perms ) = @ARGV; my $dir = Win32::Perms::new( $path ) || die $!; print "\nPath: " . $dir->Path(); ## map args to valid ace permissions ## found at http://www.roth.net/perl/perms/#Table1 my %args_to_perms = ( READ => READ, WRITE => WRITE, FULL => FULL, ALL => ALL, CHANGE => CHANGE, DELETE => DELETE, EXECUTE => EXECUTE, NO_ACCESS => NO_ACCESS, ); ## build full perms list my $perms; $perms |= $args_to_perms{$_} for @requested_perms; ## add access control entry $dir->Allow( 'MYDOMAIN\bloggJo', $perms, ACCESS_ALLOWED_ACE_TYPE, OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE ); $dir->Set() ? print "\nDone\n"; : print "\nFailed\n";
~Particle *accelerates*
|
|---|