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

hi monks,

How to set user previlages to the files and directories through perl program.

Im working with windows 2000.

Many thanks in advance.

cheers.

Replies are listed 'Best First'.
Re: user previlage in windows
by neeraj (Scribe) on Jul 06, 2004 at 10:55 UTC
    why don't you use Win32::File.
    For example if you want to make foo.txt read_only :-
    use Win32::File; Win32::File::GetAttributes("foo.txt", $attrib) || die $!; Win32::File::SetAttributes("foo.txt", $attrib | READONLY) || die $!;
    cheers.

      but if you want to make foo.txt readable only by foo_user and administrators?

      ____
      HTH, Dominique
      My two favorites:
      If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
      Bien faire, et le faire savoir...

Re: user previlage in windows
by dfaure (Chaplain) on Jul 06, 2004 at 07:35 UTC
    Im working with windows 2000

    Then you'll need the Win32::Perms package from Roth Consulting.

    ____
    HTH, Dominique
    My two favorites:
    If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
    Bien faire, et le faire savoir...

        Then you'll need the Win32::Perms package from Roth Consulting.
      Duly noted, Mr. Roth.

      </CYNICISM>

      --
      tbone1, YAPS (Yet Another Perl Schlub)
      And remember, if he succeeds, so what.
      - Chick McGee

        Duly noted, Mr. Roth.

        You're right :-)

        <awareness help_with="spare_time">
            You may do it yourself with Win32::API
        </awareness>

        ____
        HTH, Dominique
        My two favorites:
        If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
        Bien faire, et le faire savoir...

Re: user previlage in windows
by beable (Friar) on Jul 06, 2004 at 07:15 UTC
    Have you tried using the chmod function, which is the standard way to set privileges using Perl? You also should look at the chown function.

    --

    Please read perldoc perldoc.

      chmod and chown assume a Unix-ish permissions system. Win32's is very different.