ellem has asked for the wisdom of the Perl Monks concerning the following question:

Looking for a Perlish way to remove users from a Win32 directory.

The idea being that:

User A
User B
User C
Are all working on F:\Work_Dir and User A needs to make changes to the directory and no other person can be using the files. So the script is run and in the end only User A remains connected to the directory and after some amount of time the users B & C can log back on.

Is this reasonable from a scripting standpoint? And I do realize this "rude" but it is the way it is for non technical reasons.
--
ellem@optonline.net
There's more than one way to do it, but only some of them actually work.

Replies are listed 'Best First'.
Re: Removing users from a directory
by earthboundmisfit (Chaplain) on Jan 10, 2003 at 15:29 UTC
    You need to define "using the files" more fully. If you simply mean that no other user should have read/write access to the files while User A is doing something to the directory through a Perl script, then file locking by means of a semaphore file is the best way to handle this. If you mean that no one else can have access to the files via any means, you will need to set permissions on an OS level. For Win32, this is done with a module: Win32::FileSecurity

    For a good example of semaphore file locking have a look at this node

    HTH

    ---- I am what I read

Re: Removing users from a directory
by foxops (Monk) on Jan 10, 2003 at 15:33 UTC
    Have you looked at Win32::FileSecurity ?
    # Gets existing DACL and modifies Administrator rights use Win32::FileSecurity qw(MakeMask Get Set); # These masks show up as Full Control in File Manager $file = MakeMask( qw( FULL ) ); $dir = MakeMask( qw( FULL GENERIC_ALL ) ); foreach( @ARGV ) { s/\\$//; next unless -e; Get( $_, \%hash ) ; $hash{Administrator} = ( -d ) ? $dir : $file ; Set( $_, \%hash ) ; }
    Update: Oops, earthboundmisfit beat me :(
      Have you looked at Win32::FileSecurity ?

      No, and I should be. Thanks
      --
      ellem@optonline.net
      There's more than one way to do it, but only some of them actually work.
Re: Removing users from a directory
by Ryszard (Priest) on Jan 10, 2003 at 15:25 UTC
    Sounds like you need CVS IMO.

    I dont know of a way to do this unless all your users are using a controlling interface to the files..